You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using that object with an API, it might happen that the API returns a passed float(1e10) as string "10000000000". That is interpreted by pydantic as an int but is bigger than int32, thus it causes an error:
File "pydantic/main.py", line 526, in pydantic.main.BaseModel.parse_obj
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 2 validation errors for SomeObject
some_float
value is not a valid float (type=type_error.float)
some_float
ensure this value is less than or equal to 2147483647 (type=value_error.number.not_le; limit_value=2147483647)
Instead, it should interpret the number always as float, as specified in the openapi specs.
openapi-generator version
6.6.0
Related issues/PRs
The problem was probably introduced in #15124, which was written by @wing328 and reviewed by @spacether.
Bug Report Checklist
Description
With this openapi-object:
the generator from version 6.6.0 generates this object:
When using that object with an API, it might happen that the API returns a passed
float(1e10)
as string "10000000000". That is interpreted by pydantic as anint
but is bigger than int32, thus it causes an error:errors with
Instead, it should interpret the number always as float, as specified in the openapi specs.
openapi-generator version
6.6.0
Related issues/PRs
The problem was probably introduced in #15124, which was written by @wing328 and reviewed by @spacether.
Suggest a fix
We should use the
format
attribute of the API specification. If it isfloat
ordouble
, don't add theconint
to the generated python code. This probably requires changes in these lines.Note: I cannot use the
mapNumberTo: float
cli option, as other numbers with an unspecified format are and should stay integersThe text was updated successfully, but these errors were encountered: