xuri / xgen

XSD (XML Schema Definition) parser and Go/C/Java/Rust/TypeScript code generator
BSD 3-Clause "New" or "Revised" License
313 stars 74 forks source link

Type overrides? #75

Open halostatue opened 2 months ago

halostatue commented 2 months ago

Is your feature request related to a problem? Please describe.

The choice (in Go) to use float64 to represent xsd:decimal is an incorrect choice because decimal does not have the data loss issues associated with floating point numbers. It would be useful to be able to specify overrides for those types.

Describe the solution you'd like

$ xgen -i XSD -l Go -o PATH --type decimal=string
# the generated file uses `string` where `xsd:decimal` was present
$ xgen -i XSD -l Go -o PATH --type decimal=decimal --go-type-import decimal github.com/ericlagergren/decimal
# the generated file uses `decimal` where `xsd:decimal` was present and imports `github.com/ericlagergren/decimal`

Describe alternatives you've considered

Post-code generation modifications. These are primarily unsuitable because there are use cases where float64 would be used natively.