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
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When a type in an anyOf directive contains a required field then the generated class makes that field also required even though that particular type may not be present in the data.
As as example, take the enclosed Pets model from the official OpenAPI guide. The generated kotlin class is as follows:
With this class it is impossible to construct an instance for the valid model {"age": 3} because the petType field (from the other anyOf type) is missing.
I'm afraid Kotlin's type system is not strong enough to express these kinds of nullability nuances. A good enough approach would be to make all the generated fields nullable.
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
When a type in an
anyOf
directive contains a required field then the generated class makes that field also required even though that particular type may not be present in the data.As as example, take the enclosed Pets model from the official OpenAPI guide. The generated kotlin class is as follows:
With this class it is impossible to construct an instance for the valid model
{"age": 3}
because thepetType
field (from the otheranyOf
type) is missing.openapi-generator version
Both 7.5.0 and latest (master).
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
PetsPatchRequest
classSuggest a fix
I'm afraid Kotlin's type system is not strong enough to express these kinds of nullability nuances. A good enough approach would be to make all the generated fields nullable.
The text was updated successfully, but these errors were encountered: