Skip to content

[KOTLIN-SPRING/KOTLIN-CLIENT] BUG - fix json deserialization when kotlin attribute name differs from json attribute name#24036

Open
Picazsoo wants to merge 4 commits into
OpenAPITools:masterfrom
Picazsoo:feature/fix-json-deserialization-when-nameMappings
Open

[KOTLIN-SPRING/KOTLIN-CLIENT] BUG - fix json deserialization when kotlin attribute name differs from json attribute name#24036
Picazsoo wants to merge 4 commits into
OpenAPITools:masterfrom
Picazsoo:feature/fix-json-deserialization-when-nameMappings

Conversation

@Picazsoo

@Picazsoo Picazsoo commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

When using e.g. nameMappings or just depending on the generator's substitution logic to safely escape json properties names for kotlin parameters, the currently generated @get:JsonProperty("...") is not sufficient to allow safe deserialization as it only handles serialization via the getter association. Hence I added also @param:JsonProperty("...") to also allow proper deserialization.

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. - Tagging: @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10) @dennisameling (2026/02)

Summary by cubic

Fixes Jackson deserialization in generated Kotlin models by adding @param:JsonProperty so constructor params bind to the original JSON keys. Models now deserialize correctly when fields are renamed via name mappings or auto-renamed (e.g., digit-starting names).

  • Bug Fixes
    • Add @param:JsonProperty next to @get:JsonProperty in kotlin-client and kotlin-spring templates for required and optional vars.
    • Use the original JSON key for the param annotation to honor nameMappings and backtick-escaped identifiers.
    • Add tests for mapped and digit-starting fields (client and spring), include a small OAS spec, and stabilize a spring test by extending its lookup window.
    • Regenerate Kotlin samples to include the new annotations.

Written for commit d1976d7. Summary will update on new commits.

Review in cubic

@Picazsoo Picazsoo changed the title Feature/fix json deserialization when name mappings [KOTLIN-SPRING/KOTLIN-CLIENT] BUG - fix json deserialization when kotlin attribute name differs from json attribute name Jun 15, 2026
@Picazsoo Picazsoo marked this pull request as ready for review June 15, 2026 21:55

@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 255 files

Note: This PR contains a large number of files. cubic only reviews up to 100 files per PR, so some files may not have been reviewed. cubic prioritizes the most important files to review.
On a pro plan you can use ultrareview for larger PRs.

Re-trigger cubic

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant