[KOTLIN-SPRING] - add support for 'openApiNullable' - jackson nullable library to handle non-required AND nullable: true properties#23804
[KOTLIN-SPRING] - add support for 'openApiNullable' - jackson nullable library to handle non-required AND nullable: true properties#23804Picazsoo wants to merge 9 commits into
Conversation
…dle optional and nullable properties
…dle optional and nullable properties
There was a problem hiding this comment.
No issues found across 270 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
There was a problem hiding this comment.
No issues found across 270 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
|
|
||
| if (isUseJackson3()) { | ||
| // Override databind imports for Jackson 3 | ||
| importMapping.put("JsonDeserialize", "tools.jackson.databind.annotation.JsonDeserialize"); |
There was a problem hiding this comment.
this was not being set anywhere until now as far as I can tell. So on jackson 2 the JsonDeserialize simply was not imported.
Purpose of this PR is to allow proper handling of
nullable: trueattributes that are not included in the list ofrequiredattributes. This is needed to be able to handle e.g. JSON Merge Patch (RFC 7396) - ability to differentiate between omitting an attribute in the json or explicitly setting it to null to either skip modifying it / set it to null.This is already supported in java spring codegen, so this brings the two spring generators closer to feature parity.
The feature is opt-in by setting 'openApiNullable' to
true.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)"fixes #123"present in the PR description)Summary by cubic
Adds
openApiNullablesupport to Kotlin Spring generators to correctly model optional + nullable properties with a 3‑state type. Enable withopenApiNullable: trueto useJsonNullable, reject explicit nulls where not allowed, and have the generator add the dependency and module wiring.New Features
openApiNullableoption for Kotlin Spring generators.required: false, nullable: truetoJsonNullable<T>(present/null/absent).@JsonSetter(nulls = Nulls.FAIL)for optional non‑nullable fields.JsonNullableModulebean in the generated Spring Boot app.org.openapitools:jackson-databind-nullableto generated Gradle/Maven files (SB2 uses 0.2.8; SB3/SB4 use 0.2.10).jackson-databind-nullable≥ 0.2.10 for Jackson 3).$reftypes; samples regenerated.Refactors
OPENAPI_NULLABLEinCodegenConstantsand aligned usage across Java/Kotlin codegens.springBootApplication.mustachestructure and conditional module registration.Written for commit 1cbd619. Summary will update on new commits. Review in cubic