-
-
Notifications
You must be signed in to change notification settings - Fork 229
Incorrect parsing of null as nullable enum value serialized as strings #1243
New issue
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
Comments
It looks like you're using OpenAPI 3.0, which explicitly states
I believe the solution is to use |
Not sure if exactly the same, but i'm encountering a similar issue when updating from 0.24.0 to 0.24.1 or higher. {
"x-generator": "NSwag v14.2.0.0 (NJsonSchema v11.1.0.0 (Newtonsoft.Json v13.0.0.0))",
"openapi": "3.0.0",
...
"properties": {
...
"specification": {
"nullable": true,
"$ref": "#/components/schemas/SubVariantDto"
},
...
} @classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
...
d = dict(src_dict)
...
_specification = d.pop("specification", UNSET) # <-- can be None
specification: Union[Unset, SubVariantDto]
if isinstance(_specification, Unset):
specification = UNSET
else:
specification = SubVariantDto.from_dict(_specification)
node_dto = cls(
...,
specification=specification,
...
)
return node_dto @_attrs_define
class SubVariantDto:
...
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict) # <-- crashes on None is not iterable
... In 0.24.0 or earlier the generated code would give the block below, which would not trigger the issue. @classmethod
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
...
d = src_dict.copy()
...
specification = d.pop("specification", UNSET)
...
node_dto = cls(
...
specification=specification,
...
)
return node_dto |
Consider the following schema definition (which passes validation with the
openapitools/openapi-generator-cli
container image):It looks as if openapi-python-client version 0.23.1 supports deserialization with the
deviceEncryptionKeyScheme
property being unset, but not it beingnull
:This looks like a bug to me.
The text was updated successfully, but these errors were encountered: