[BUG] [JAVA] oneOf and required does end up non-nullable where it should be nullable
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [x] Have you validated the input using an OpenAPI validator (example)?
- [x] Have you tested with the latest master to confirm the issue still exists?
- [x] Have you searched for related issues/PRs?
- [] What's the actual output vs expected output?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
For properties that are made mutually exclusive using oneOf, the generated pojo is containing @Nonnull and @JsonInclude(value = JsonInclude.Include.ALWAYS) which is wrong. The result of that is that this properties are serialized with a null value altough the should not be serialized at all.
openapi-generator version
v7.3.0 and master
OpenAPI declaration file content or url
https://gist.github.com/david0/1b3d159b4e951e1a589fac596e9a0488
Generation Details
generate -i oneOf-issue.openapi.yaml -g java --library webclient -o out
Steps to reproduce
- generate oneOf-issue.openapi.yaml
Related issues/PRs
Suggest a fix
It would be better if required properties would be turned into nullable when inlining them via oneOf.
Maybe even better that that would be to leave the nullable and JsonInclude out in this case and then one could add the required annotations via x-field-extra-annotation, giving more control what is needed in specific cases.