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
Hi there, this is a spec issue and the generator is behaving correctly. nullable: true only adds type null when used adjacent to an explicit type definition. Per the openapi spec, the value for nullable is described as: A true value adds "null" to the allowed type specified by the type keyword, only if type is explicitly defined within the same Schema Object. Other Schema Object constraints retain their defined behavior, and therefore may disallow the use of null as a value. A false value leaves the specified or default type unmodified. The default value is false.
Your oldestPet schema has no type definition, so any type is allowed in. Adding nullable: True has no impact.
To get this to work as you want you can update your spec to one of these solutions and regenerate your client
make the Pet schema nullable in the component and make oldestPet directly $ref Pet
spacether
changed the title
[BUG][python] Nullable property not taken into account when building a client
[python] Nullable property not taken into account when building a client
Dec 5, 2022
spacether
changed the title
[python] Nullable property not taken into account when building a client
[python] Nullable keyword not taken into account when building a client
Dec 5, 2022
Bug Report Checklist
Description
I'm generating a python-client based on the following OpenApi spec:
This OpenAPI spec defines the response property
oldestPet
like that:So
oldestPet
should be either aPet
object ornull
.The issue is that the generated client defines the property like that:
Where I would expect this instead:
openapi-generator version
I'm using
openapitools/openapi-generator-cli:v6.2.0
.I don't believe this is a regression but I haven't tested with previous versions.
Suggest a fix
I'd first like to confirm with others (especially @spacether) that this is indeed a bug, if that is confirmed I'll see how it can be fixed.
The text was updated successfully, but these errors were encountered: