[FIX][KOTLIN][SPRING] mark @param:JsonProperty as required in generated models when required in open api spec - #24754
Conversation
…ed models when required in open api spec
|
Hi @svenallers, thanks a lot for the fix and the test and sorry for introducing the regression in my bug fix. I was fixing a legitimate issue but definitely somehow overlooked this 🤦 Hello @wing328 , not sure when the next release is planned, but this ⬆️ would definitely make sense to include as it fixes a potentially nasty bug I introduced while fixing another legitimate bug. Two steps forward, one step back, it seems... |
Oh no worries. That happens to all of us from time to time 😉. That was not meant as blame but just as a reference. |
Fixes a kotlin-spring regression introduced in v7.24.0 (by #24036), where required primitive properties could be silently defaulted when missing in request JSON.
Related issue
Fixes #24753
What changed
@param:JsonProperty("...", required = true)@param:JsonProperty(..., required = true)@param:JsonProperty("...")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.
@karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10)
Summary by cubic
Restores required-property validation in generated Kotlin Spring models. Previously (since v7.24.0), missing required primitives could be silently defaulted because constructor params used plain @PARAM:JsonProperty; now required vars emit @PARAM:JsonProperty(..., required = true) so Jackson fails on missing fields.
required = trueon@param:JsonProperty; optional vars remain unchanged. Aligns with existing@get:JsonProperty(..., required = true).dataClassReqVar.mustachetemplate updated; tests added to assert required/optional behavior; samples regenerated.kotlin-springserver models to restore missing-field failures. No runtime/config changes.Written for commit 0ad8aff. Summary will update on new commits.