fix: honor required fields in jackson @JsonProperty annotations#21062
fix: honor required fields in jackson @JsonProperty annotations#21062elagerho wants to merge 4 commits intoOpenAPITools:masterfrom
Conversation
|
Is Circle a bit flaky maybe? Seems like all nodes do the same thing. |
|
Pinging the Java committee. Would love your input on this. @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08) |
|
thanks for the pr. i think we also need to handle the case in which the required field is nullable. ( |
|
Hi @elagerho, thanks for this PR! 👍 To rephrase, if my field is required in my OpenApi contract (required: ["my_field"] in its parent object), then the Java property in the generated file will be annotated with @JsonProperty(required=true). Is that correct? If so, I'm very interested in this PR! 😃 Ah! it seems the answer is yes. As stand in your issue report #21060 |
|
merged with #21876 with support for nullable as well. |
This PR honors required openapi fields when generating Jackson's @JsonProperty annotations. It will appropriately cause deserialization to throw if incoming JSON is not conforming. Adjacent @JsonBProperty annotations do already honor the required fields.
Tested by local override of the templates using the Java with Jackson generator. Issue here. It might be considered a breaking change, since Jackson deserialization will throw. For now filing against master.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)