We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
after upgrading from xsdata version 20.11 to 22.11 I have discovered a problem converting an xsd to dataclass defintions
given for example this subset of the xsd file
<xs:complexType name="chargeType"> <xs:all> <xs:element name="amount" type="monetaryType" minOccurs="1" maxOccurs="1"> <xs:annotation> <xs:documentation> The amount of the charge (currently in USD) </xs:documentation> </xs:annotation> </xs:element> </xs:all> </xs:complexType> <xs:simpleType name="monetaryType"> <xs:annotation> <xs:documentation>Cost</xs:documentation> </xs:annotation> <xs:restriction base="xs:decimal"> <xs:pattern value="\d+\.\d{2}"/> </xs:restriction> </xs:simpleType>
the python type declaration under 20.11 changed from decimal.Decimal
decimal.Decimal
amount: Optional[decimal.Decimal] = field( default=None, metadata={ "type": "Element", "namespace": "", "required": True, "pattern": r"\d+\.\d{2}", } )
to str under 22.11
str
amount: Optional[str] = field( default=None, metadata={ "type": "Element", "namespace": "", "required": True, "pattern": r"\d+\.\d{2}", } )
Is this an expected change?
thanks
The text was updated successfully, but these errors were encountered:
Yeah xsdata can't handle patterns yet, so whenever a pattern is present it resets the type to str,
The pattern is added in the metadata for future reference but it's not used yet, maybe I could add an option to ignore patterns completely?
Sorry, something went wrong.
HI @bkcsfi I added a new option to ignore-patterns,
xsdata schema.xsd --ignore-patterns
https://xsdata.readthedocs.io/en/latest/codegen.html
At some point I really want to do this properly but it's not very easy to translate xsd regex to python
Successfully merging a pull request may close this issue.
after upgrading from xsdata version 20.11 to 22.11 I have discovered a problem converting an xsd to dataclass defintions
given for example this subset of the xsd file
the python type declaration under 20.11 changed from
decimal.Decimal
to
str
under 22.11Is this an expected change?
thanks
The text was updated successfully, but these errors were encountered: