Skip to content

[FIX][KOTLIN][SPRING] mark @param:JsonProperty as required in generated models when required in open api spec - #24754

Merged
wing328 merged 2 commits into
OpenAPITools:masterfrom
svenallers:required-regression
Aug 24, 2026
Merged

[FIX][KOTLIN][SPRING] mark @param:JsonProperty as required in generated models when required in open api spec#24754
wing328 merged 2 commits into
OpenAPITools:masterfrom
svenallers:required-regression

Conversation

@svenallers

@svenallers svenallers commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

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

  • Updated required kotlin-spring model vars to emit:
    • @param:JsonProperty("...", required = true)
  • Added/updated kotlin-spring generator tests to assert:
    • required vars use @param:JsonProperty(..., required = true)
    • optional vars still use plain @param:JsonProperty("...")

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@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.

  • Behavior: required vars add required = true on @param:JsonProperty; optional vars remain unchanged. Aligns with existing @get:JsonProperty(..., required = true).
  • Diff hotspots: dataClassReqVar.mustache template updated; tests added to assert required/optional behavior; samples regenerated.
  • Migration: regenerate kotlin-spring server models to restore missing-field failures. No runtime/config changes.

Written for commit 0ad8aff. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 48 files

Re-trigger cubic

@Picazsoo

Copy link
Copy Markdown
Contributor

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...

@wing328
wing328 merged commit 8674968 into OpenAPITools:master Aug 24, 2026
80 checks passed
@wing328 wing328 added this to the 7.25.0 milestone Aug 24, 2026
@svenallers

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][KOTLIN][SPRING] Missing required primitive properties are silently defaulted after adding @param:JsonProperty to required vars in v7.24.0

3 participants