Closed mikthemonster closed 3 years ago
You can't try using the type mappings field to map int and double to num.
However, this is going to apply it throughout the generated code.
Other option will be to ensure the api returns the right type always
You can't try using the type mappings field to map int and double to num.
Hmmm, im not sure how to do that... Do you have an example or can you guide me?
The error is related to this line of autogenerated code:
totalPrice: json[r'totalPrice'],
It happens when totalPrice does not contain a "." (default behavior in .net core 5 when the double value does not contain any decimals)
The openapi annotation has a typeMappings property that takes a map of string. Add a mapping for int and double to num
@Openapi(
...
typeMappings:{'int':'num','double':'num'}
...
)
@Openapi( ... typeMappings:{'int':'num','double':'num'} ... )
Thanks, its working! :-)
Hi,
My API (.net core 5.0) sometimes returns double values without the decimal point:
"totalPrice": 1
instead of:
totalPrice": 1.0
Unfortunately this gives an error:
type 'int' is not a subtype of type 'double'
Can I somehow fix this without changing the auto-generated files?