From e1adee27bff874fbb39328e083b6e7ee3d3595dc Mon Sep 17 00:00:00 2001 From: Jachym Metlicka Date: Sun, 17 May 2026 15:03:48 +0200 Subject: [PATCH 1/9] feat(kotlin): add support for OpenAPI Jackson Nullable library to handle optional and nullable properties --- docs/generators/kotlin-spring.md | 3 +- .../codegen/CodegenConstants.java | 3 + .../languages/AbstractJavaCodegen.java | 2 +- .../languages/KotlinSpringServerCodegen.java | 61 +++++- .../kotlin-spring/dataClassOptVar.mustache | 5 +- .../spring-boot/buildGradle-sb3-Kts.mustache | 2 + .../spring-boot/buildGradle-sb4-Kts.mustache | 2 + .../spring-boot/buildGradleKts.mustache | 2 + .../libraries/spring-boot/pom-sb3.mustache | 6 + .../libraries/spring-boot/pom-sb4.mustache | 6 + .../libraries/spring-boot/pom.mustache | 6 + .../spring-cloud/buildGradle-sb3-Kts.mustache | 2 + .../spring-cloud/buildGradle-sb4-Kts.mustache | 2 + .../spring-cloud/buildGradleKts.mustache | 2 + .../libraries/spring-cloud/pom-sb3.mustache | 6 + .../libraries/spring-cloud/pom-sb4.mustache | 6 + .../libraries/spring-cloud/pom.mustache | 7 + .../codegen/java/JavaClientCodegenTest.java | 9 +- .../java/spring/SpringCodegenTest.java | 8 +- .../spring/KotlinSpringServerCodegenTest.java | 188 ++++++++++++++++-- .../kotlin/required-nullable-4-states.yaml | 40 ++++ 21 files changed, 329 insertions(+), 39 deletions(-) create mode 100644 modules/openapi-generator/src/test/resources/3_0/kotlin/required-nullable-4-states.yaml diff --git a/docs/generators/kotlin-spring.md b/docs/generators/kotlin-spring.md index 584c4e1c9cb3..df2ec9ff370a 100644 --- a/docs/generators/kotlin-spring.md +++ b/docs/generators/kotlin-spring.md @@ -45,6 +45,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |modelMutable|Create mutable models| |false| |modelPackage|model package for generated code| |org.openapitools.model| |packageName|Generated artifact package name.| |org.openapitools| +|openApiNullable|Enable OpenAPI Jackson Nullable library (org.openapitools.jackson.nullable.JsonNullable) to represent `required: false, nullable: true` schema properties as a 3-state type (present/null/absent). Adds `jackson-databind-nullable` dependency to generated build files. Compatible with both Jackson 2 and Jackson 3 (requires jackson-databind-nullable ≥ 0.2.10).| |false| |parcelizeModels|toggle "@Parcelize" for generated models| |null| |reactive|use coroutines for reactive behavior| |false| |requestMappingMode|Where to generate the class level @RequestMapping annotation.|
**api_interface**
Generate the @RequestMapping annotation on the generated Api Interface.
**controller**
Generate the @RequestMapping annotation on the generated Api Controller Implementation.
**none**
Do not add a class level @RequestMapping annotation.
|controller| @@ -64,7 +65,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |useDeductionForOneOfInterfaces|Annotate discriminator-free oneOf interfaces with Jackson's @JsonTypeInfo(use = Id.DEDUCTION) and @JsonSubTypes so the concrete subtype is resolved from the JSON field set rather than a type-tag property. Has no effect when a discriminator is present (name-based resolution is used instead). Requires subtypes to have structurally distinct sets of properties.| |false| |useFeignClientUrl|Whether to generate Feign client with url parameter.| |true| |useFlowForArrayReturnType|Whether to use Flow for array/collection return types when reactive is enabled. If false, will use List instead.| |true| -|useJackson3|Use Jackson 3 dependencies (tools.jackson package). Only available with `useSpringBoot4`. Defaults to true when `useSpringBoot4` is enabled. Incompatible with `openApiNullable`.| |false| +|useJackson3|Use Jackson 3 dependencies (tools.jackson package). Only available with `useSpringBoot4`. Defaults to true when `useSpringBoot4` is enabled. Compatible with `openApiNullable` (requires jackson-databind-nullable ≥ 0.2.10).| |false| |useResponseEntity|Whether (when false) to return actual type (e.g. List<Fruit>) and handle non-happy path responses via exceptions flow or (when true) return entire ResponseEntity (e.g. ResponseEntity<List<Fruit>>). If disabled, method are annotated using a @ResponseStatus annotation, which has the status of the first response declared in the Api definition| |true| |useSealedResponseInterfaces|Generate sealed interfaces for endpoint responses that all possible response types implement. Allows controllers to return any valid response type in a type-safe manner (e.g., sealed interface CreateUserResponse implemented by User, ConflictResponse, ErrorResponse)| |false| |useSpringBoot3|Generate code and provide dependencies for use with Spring Boot ≥ 3 (use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java index b2a4de1201e9..713bc8f7bf9f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenConstants.java @@ -229,6 +229,9 @@ public class CodegenConstants { public static final String NULLABLE_REFERENCE_TYPES = "nullableReferenceTypes"; public static final String NULLABLE_REFERENCE_TYPES_DESC = "Use nullable annotations in the project. Only supported on C# 8 / ASP.NET Core 3.1 or newer."; + public static final String OPENAPI_NULLABLE = "openApiNullable"; + public static final String OPENAPI_NULLABLE_DESC = "Enable OpenAPI Jackson Nullable library (jackson-databind-nullable) for optional + nullable properties."; + public static final String TEMPLATING_ENGINE = "templatingEngine"; public static final String TEMPLATING_ENGINE_DESC = "The templating engine plugin to use: \"mustache\" (default) or \"handlebars\" (beta)"; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java index 6cf3ca55fee2..b4d025415f18 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java @@ -102,7 +102,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code public static final String ADDITIONAL_ONE_OF_TYPE_ANNOTATIONS = "additionalOneOfTypeAnnotations"; public static final String ADDITIONAL_ENUM_TYPE_ANNOTATIONS = "additionalEnumTypeAnnotations"; public static final String DISCRIMINATOR_CASE_SENSITIVE = "discriminatorCaseSensitive"; - public static final String OPENAPI_NULLABLE = "openApiNullable"; + public static final String OPENAPI_NULLABLE = CodegenConstants.OPENAPI_NULLABLE; public static final String JACKSON = "jackson"; public static final String TEST_OUTPUT = "testOutput"; public static final String IMPLICIT_HEADERS = "implicitHeaders"; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java index e3315a25cea7..1f6f9e582a18 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java @@ -181,6 +181,7 @@ public String getDescription() { @Setter private boolean substituteGenericPagedModel = false; @Setter private boolean useSealedResponseInterfaces = false; @Setter private boolean companionObject = false; + @Getter @Setter private boolean openApiNullable = false; @Getter @Setter protected boolean useDeductionForOneOfInterfaces = false; @@ -290,7 +291,7 @@ public KotlinSpringServerCodegen() { " (contexts) added to single project.", beanQualifiers); addSwitch(USE_SPRING_BOOT3, "Generate code and provide dependencies for use with Spring Boot ≥ 3 (use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.", useSpringBoot3); addSwitch(USE_SPRING_BOOT4, "Generate code and provide dependencies for use with Spring Boot 4.x. Enabling this option will also enable `useJakartaEe`.", useSpringBoot4); - addSwitch(USE_JACKSON_3, "Use Jackson 3 dependencies (tools.jackson package). Only available with `useSpringBoot4`. Defaults to true when `useSpringBoot4` is enabled. Incompatible with `openApiNullable`.", useJackson3); + addSwitch(USE_JACKSON_3, "Use Jackson 3 dependencies (tools.jackson package). Only available with `useSpringBoot4`. Defaults to true when `useSpringBoot4` is enabled.", useJackson3); addSwitch(USE_FLOW_FOR_ARRAY_RETURN_TYPE, "Whether to use Flow for array/collection return types when reactive is enabled. If false, will use List instead.", useFlowForArrayReturnType); addSwitch(INCLUDE_HTTP_REQUEST_CONTEXT, "Whether to include HttpServletRequest (blocking) or ServerWebExchange (reactive) as additional parameter in generated methods.", includeHttpRequestContext); addSwitch(USE_RESPONSE_ENTITY, @@ -314,6 +315,12 @@ public KotlinSpringServerCodegen() { substituteGenericPagedModel); addSwitch(COMPANION_OBJECT, "Whether to generate companion objects in data classes, enabling companion extensions.", companionObject); cliOptions.add(CliOption.newBoolean(CodegenConstants.USE_DEDUCTION_FOR_ONE_OF_INTERFACES, CodegenConstants.USE_DEDUCTION_FOR_ONE_OF_INTERFACES_DESC, useDeductionForOneOfInterfaces)); + addSwitch(CodegenConstants.OPENAPI_NULLABLE, + "Enable OpenAPI Jackson Nullable library (jackson-databind-nullable) for optional + nullable " + + "properties (required: false, nullable: true). When enabled, such properties use " + + "JsonNullable = JsonNullable.undefined() so callers can distinguish between a missing key " + + "and an explicitly provided null. Requires jackson-databind-nullable >= 0.2.10 when used with useJackson3.", + openApiNullable); supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application."); supportedLibraries.put(SPRING_CLOUD_LIBRARY, "Spring-Cloud-Feign client with Spring-Boot auto-configured settings."); @@ -546,6 +553,15 @@ public void processOpts() { if (isUseJackson3()) { // Override databind imports for Jackson 3 importMapping.put("JsonDeserialize", "tools.jackson.databind.annotation.JsonDeserialize"); + importMapping.put("JsonSetter", "tools.jackson.annotation.JsonSetter"); + importMapping.put("Nulls", "tools.jackson.annotation.Nulls"); + // jackson-databind-nullable >= 0.2.10 supports both Jackson 2 and 3; + // the JsonNullable class lives in the same package regardless of Jackson version. + importMapping.put("JsonNullable", "org.openapitools.jackson.nullable.JsonNullable"); + } else { + importMapping.put("JsonSetter", "com.fasterxml.jackson.annotation.JsonSetter"); + importMapping.put("Nulls", "com.fasterxml.jackson.annotation.Nulls"); + importMapping.put("JsonNullable", "org.openapitools.jackson.nullable.JsonNullable"); } // Spring-specific import mappings for x-spring-paginated support @@ -767,10 +783,10 @@ public void processOpts() { throw new IllegalArgumentException("useJackson3 is only available with Spring Boot >= 4"); } - if (isUseJackson3() && additionalProperties.containsKey("openApiNullable") - && Boolean.parseBoolean(additionalProperties.get("openApiNullable").toString())) { - throw new IllegalArgumentException("openApiNullable cannot be set with useJackson3"); + if (additionalProperties.containsKey(CodegenConstants.OPENAPI_NULLABLE)) { + this.setOpenApiNullable(convertPropertyToBoolean(CodegenConstants.OPENAPI_NULLABLE)); } + writePropertyBack(CodegenConstants.OPENAPI_NULLABLE, openApiNullable); if (isUseSpringBoot3() || isUseSpringBoot4()) { if (AnnotationLibrary.SWAGGER1.equals(getAnnotationLibrary())) { @@ -1321,6 +1337,21 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert property.example = null; } + // Scenario 3: optional + non-nullable → block explicit JSON nulls via @JsonSetter(nulls = Nulls.FAIL). + // Missing keys still succeed (default = null is used), but explicit {"field": null} fails deserialization. + if (!Boolean.TRUE.equals(property.required) && !Boolean.TRUE.equals(property.isNullable)) { + property.vendorExtensions.put("x-has-json-setter-nulls-fail", true); + model.imports.add("JsonSetter"); + model.imports.add("Nulls"); + } + + // Scenario 4: optional + nullable with openApiNullable → use JsonNullable = JsonNullable.undefined() + // so callers can distinguish between a missing key and an explicitly provided null. + if (openApiNullable && !Boolean.TRUE.equals(property.required) && Boolean.TRUE.equals(property.isNullable)) { + property.vendorExtensions.put("x-is-jackson-optional-nullable", true); + model.imports.add("JsonNullable"); + } + //Add imports for Jackson if (!Boolean.TRUE.equals(model.isEnum)) { model.imports.add("JsonProperty"); @@ -1475,6 +1506,28 @@ public ModelsMap postProcessModelsEnum(ModelsMap objs) { //Add imports for Jackson List> imports = objs.getImports(); + // Set 4-state nullable/required vendor extensions on optionalVars instances. + // optionalVars are cloned independently from vars by removeAllDuplicatedProperty(), + // so they require a separate pass here — postProcessModelProperty only covers vars. + for (ModelMap mo : objs.getModels()) { + CodegenModel cm = mo.getModel(); + for (CodegenProperty var : cm.optionalVars) { + // Scenario 3: optional + non-nullable → block explicit JSON nulls via @JsonSetter(nulls = Nulls.FAIL) + if (!var.required && !var.isNullable) { + var.vendorExtensions.put("x-has-json-setter-nulls-fail", true); + } + // Scenario 4: optional + nullable with openApiNullable → use JsonNullable + if (openApiNullable && !var.required && var.isNullable) { + var.vendorExtensions.put("x-is-jackson-optional-nullable", true); + if (importMapping.containsKey("JsonNullable")) { + Map item = new HashMap<>(); + item.put("import", importMapping.get("JsonNullable")); + imports.add(item); + } + } + } + } + objs.getModels().stream() .map(ModelMap::getModel) .filter(cm -> Boolean.TRUE.equals(cm.isEnum) && cm.allowableValues != null) diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/dataClassOptVar.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/dataClassOptVar.mustache index ab575d4bf9d3..404692bece79 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/dataClassOptVar.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/dataClassOptVar.mustache @@ -2,5 +2,6 @@ @Schema({{#example}}example = "{{#lambdaRemoveLineBreak}}{{#lambdaEscapeInNormalString}}{{{.}}}{{/lambdaEscapeInNormalString}}{{/lambdaRemoveLineBreak}}", {{/example}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}description = "{{{description}}}"){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}} @ApiModelProperty({{#example}}example = "{{#lambdaRemoveLineBreak}}{{#lambdaEscapeInNormalString}}{{{.}}}{{/lambdaEscapeInNormalString}}{{/lambdaRemoveLineBreak}}", {{/example}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swagger1AnnotationLibrary}}{{#deprecated}} @Deprecated(message = ""){{/deprecated}}{{#vendorExtensions.x-field-extra-annotation}} - {{{.}}}{{/vendorExtensions.x-field-extra-annotation}} - @get:JsonProperty("{{{baseName}}}"){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{{nameInPascalCase}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{^defaultValue}}null{{/defaultValue}}{{#defaultValue}}{{^isNumber}}{{{defaultValue}}}{{/isNumber}}{{#isNumber}}{{{dataType}}}("{{{defaultValue}}}"){{/isNumber}}{{/defaultValue}} \ No newline at end of file + {{{.}}}{{/vendorExtensions.x-field-extra-annotation}}{{#vendorExtensions.x-has-json-setter-nulls-fail}} + @field:JsonSetter(nulls = Nulls.FAIL){{/vendorExtensions.x-has-json-setter-nulls-fail}} + @get:JsonProperty("{{{baseName}}}"){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#vendorExtensions.x-is-jackson-optional-nullable}}JsonNullable<{{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{{nameInPascalCase}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}>{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{{nameInPascalCase}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}?{{/vendorExtensions.x-is-jackson-optional-nullable}} = {{#vendorExtensions.x-is-jackson-optional-nullable}}JsonNullable.undefined(){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^defaultValue}}null{{/defaultValue}}{{#defaultValue}}{{^isNumber}}{{{defaultValue}}}{{/isNumber}}{{#isNumber}}{{{dataType}}}("{{{defaultValue}}}"){{/isNumber}}{{/defaultValue}}{{/vendorExtensions.x-is-jackson-optional-nullable}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradle-sb3-Kts.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradle-sb3-Kts.mustache index f1e1004e19b9..8a7266a6bce9 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradle-sb3-Kts.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradle-sb3-Kts.mustache @@ -52,6 +52,8 @@ dependencies { {{#useBeanValidation}} implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api"){{/useBeanValidation}} +{{#openApiNullable}} + implementation("org.openapitools:jackson-databind-nullable:0.2.10"){{/openApiNullable}} implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradle-sb4-Kts.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradle-sb4-Kts.mustache index 17b49c0ef674..bdf1f366663a 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradle-sb4-Kts.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradle-sb4-Kts.mustache @@ -61,6 +61,8 @@ dependencies { {{#useBeanValidation}} implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api"){{/useBeanValidation}} +{{#openApiNullable}} + implementation("org.openapitools:jackson-databind-nullable:0.2.10"){{/openApiNullable}} implementation("jakarta.annotation:jakarta.annotation-api:3.0.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradleKts.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradleKts.mustache index ec356c78edea..b91a8885ca47 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradleKts.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/buildGradleKts.mustache @@ -59,6 +59,8 @@ dependencies { {{#useBeanValidation}} implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api"){{/useBeanValidation}} +{{#openApiNullable}} + implementation("org.openapitools:jackson-databind-nullable:0.2.8"){{/openApiNullable}} implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb3.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb3.mustache index e37830419c9a..e48fc8d6772b 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb3.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb3.mustache @@ -197,6 +197,12 @@ org.springframework.boot spring-boot-starter-validation {{/useBeanValidation}} +{{#openApiNullable}} + + org.openapitools + jackson-databind-nullable + 0.2.10 + {{/openApiNullable}} jakarta.annotation jakarta.annotation-api diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb4.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb4.mustache index 5847572ef0aa..1a8d34689c06 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb4.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb4.mustache @@ -203,6 +203,12 @@ org.springframework.boot spring-boot-starter-validation {{/useBeanValidation}} +{{#openApiNullable}} + + org.openapitools + jackson-databind-nullable + 0.2.10 + {{/openApiNullable}} jakarta.annotation jakarta.annotation-api diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom.mustache index 8765049c3494..b73f2498dfd8 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom.mustache @@ -184,6 +184,12 @@ org.springframework.boot spring-boot-starter-validation {{/useBeanValidation}} +{{#openApiNullable}} + + org.openapitools + jackson-databind-nullable + 0.2.8 + {{/openApiNullable}} javax.annotation javax.annotation-api diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/buildGradle-sb3-Kts.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/buildGradle-sb3-Kts.mustache index 17625708d986..335432ea1219 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/buildGradle-sb3-Kts.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/buildGradle-sb3-Kts.mustache @@ -62,6 +62,8 @@ dependencies { {{#useBeanValidation}} implementation("jakarta.validation:jakarta.validation-api"){{/useBeanValidation}} +{{#openApiNullable}} + implementation("org.openapitools:jackson-databind-nullable:0.2.10"){{/openApiNullable}} implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") } diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/buildGradle-sb4-Kts.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/buildGradle-sb4-Kts.mustache index bf52cff383e6..46e0a213b740 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/buildGradle-sb4-Kts.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/buildGradle-sb4-Kts.mustache @@ -71,6 +71,8 @@ dependencies { {{#useBeanValidation}} implementation("jakarta.validation:jakarta.validation-api"){{/useBeanValidation}} +{{#openApiNullable}} + implementation("org.openapitools:jackson-databind-nullable:0.2.10"){{/openApiNullable}} implementation("jakarta.annotation:jakarta.annotation-api:3.0.0") } \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/buildGradleKts.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/buildGradleKts.mustache index d8bae3cc9c12..dbbc8f2f908d 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/buildGradleKts.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/buildGradleKts.mustache @@ -69,6 +69,8 @@ dependencies { {{#useBeanValidation}} implementation("javax.validation:validation-api"){{/useBeanValidation}} +{{#openApiNullable}} + implementation("org.openapitools:jackson-databind-nullable:0.2.8"){{/openApiNullable}} implementation("javax.annotation:javax.annotation-api:1.3.2") } diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb3.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb3.mustache index 3ab6582ac525..791fc9cd40a2 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb3.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb3.mustache @@ -218,6 +218,12 @@ jakarta.validation jakarta.validation-api {{/useBeanValidation}} +{{#openApiNullable}} + + org.openapitools + jackson-databind-nullable + 0.2.10 + {{/openApiNullable}} jakarta.annotation jakarta.annotation-api diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb4.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb4.mustache index 8615b298bf3b..ee4ebda17098 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb4.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb4.mustache @@ -224,6 +224,12 @@ jakarta.validation jakarta.validation-api {{/useBeanValidation}} +{{#openApiNullable}} + + org.openapitools + jackson-databind-nullable + 0.2.10 + {{/openApiNullable}} jakarta.annotation jakarta.annotation-api diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom.mustache index 0296d383952f..47fb42f7ae55 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom.mustache @@ -200,6 +200,13 @@ validation-api {{/useBeanValidation}} + {{#openApiNullable}} + + org.openapitools + jackson-databind-nullable + 0.2.8 + + {{/openApiNullable}} javax.annotation javax.annotation-api diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java index d34e05dfdfd2..42a46f9e0049 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java @@ -732,8 +732,7 @@ void supportsJackson3WithOpenApiNullableForSpringBoot4Libraries(String library) .setLibrary(library) .addAdditionalProperty(USE_JACKSON_3, true) .addAdditionalProperty(USE_SPRING_BOOT4, true) - .addAdditionalProperty(OPENAPI_NULLABLE, true) - .setInputSpec("src/test/resources/3_0/java/autoset_constant.yaml") + .addAdditionalProperty(JavaClientCodegen.OPENAPI_NULLABLE, true) .setOutputDir(outputDir); List files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate(); @@ -3001,7 +3000,7 @@ void supportsJackson3ForSpringBoot4Libraries(String library) { .setLibrary(library) .addAdditionalProperty(USE_JACKSON_3, true) .addAdditionalProperty(USE_SPRING_BOOT4, true) - .addAdditionalProperty(OPENAPI_NULLABLE, false) + .addAdditionalProperty(JavaClientCodegen.OPENAPI_NULLABLE, false) .setInputSpec("src/test/resources/3_0/java/autoset_constant.yaml") .setOutputDir(outputDir); @@ -3027,7 +3026,7 @@ void supportsJackson3ForSpringBoot4Libraries(String library) { void gsonCodeDoesNotContainJacksonReferences(Library library) { final CodegenConfigurator configurator = new CodegenConfigurator() .addAdditionalProperty(SERIALIZATION_LIBRARY, Serializer.GSON) - .addAdditionalProperty(OPENAPI_NULLABLE, "false") + .addAdditionalProperty(JavaClientCodegen.OPENAPI_NULLABLE, "false") .setGeneratorName(JAVA_GENERATOR) .setLibrary(library.getValue()) .setInputSpec("src/test/resources/3_0/java/autoset_constant.yaml") @@ -3079,7 +3078,7 @@ void generatesJacksonJsonFormatAnnotation_whenLibraryIsJackson_andSerializeBigDe .setLibrary(JavaClientCodegen.NATIVE) .addAdditionalProperty(CodegenConstants.SERIALIZATION_LIBRARY, SERIALIZATION_LIBRARY_JACKSON) .addAdditionalProperty(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, true) - .addAdditionalProperty(OPENAPI_NULLABLE, false) + .addAdditionalProperty(JavaClientCodegen.OPENAPI_NULLABLE, false) .addGlobalProperty(CodegenConstants.MODELS, "FormatTest") .addGlobalProperty(CodegenConstants.MODEL_DOCS, "false") .addGlobalProperty(CodegenConstants.MODEL_TESTS, "false") diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java index da1e4aefface..70beabdd83d0 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java @@ -1738,7 +1738,7 @@ public void shouldGenerateValidCodeForReactiveControllerWithoutParams_issue14907 codegen.additionalProperties().put(INTERFACE_ONLY, "true"); codegen.additionalProperties().put(SKIP_DEFAULT_INTERFACE, "true"); codegen.additionalProperties().put(IMPLICIT_HEADERS, "true"); - codegen.additionalProperties().put(OPENAPI_NULLABLE, "false"); + codegen.additionalProperties().put(SpringCodegen.OPENAPI_NULLABLE, "false"); ClientOptInput input = new ClientOptInput(); input.openAPI(openAPI); @@ -1770,7 +1770,7 @@ public void shouldGenerateValidCodeWithPaginated_reactive_issue15265() throws IO codegen.additionalProperties().put(INTERFACE_ONLY, "true"); codegen.additionalProperties().put(SKIP_DEFAULT_INTERFACE, "true"); codegen.additionalProperties().put(IMPLICIT_HEADERS, "true"); - codegen.additionalProperties().put(OPENAPI_NULLABLE, "false"); + codegen.additionalProperties().put(SpringCodegen.OPENAPI_NULLABLE, "false"); ClientOptInput input = new ClientOptInput(); input.openAPI(openAPI); @@ -1803,7 +1803,7 @@ public void shouldGenerateValidCodeWithPaginated_nonReactive_issue15265() throws codegen.additionalProperties().put(INTERFACE_ONLY, "true"); codegen.additionalProperties().put(SKIP_DEFAULT_INTERFACE, "true"); codegen.additionalProperties().put(IMPLICIT_HEADERS, "true"); - codegen.additionalProperties().put(OPENAPI_NULLABLE, "false"); + codegen.additionalProperties().put(SpringCodegen.OPENAPI_NULLABLE, "false"); ClientOptInput input = new ClientOptInput(); input.openAPI(openAPI); @@ -6714,7 +6714,7 @@ public void testJspecify(String library, int springBootVersion, String fooApiFil final Map files = generateFromContract("src/test/resources/3_0/java/jspecify.yaml", library, Map.of(USE_JSPECIFY, true, CONTAINER_DEFAULT_TO_NULL, true, - OPENAPI_NULLABLE, false, + SpringCodegen.OPENAPI_NULLABLE, false, USE_BEANVALIDATION, true, INTERFACE_ONLY, false, springVersionProperty, springBootVersion > 2 diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java index 586920585f7f..ea3d049750a1 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java @@ -5246,28 +5246,16 @@ public void shouldRefuseSpringBoot3AndSpringBoot4Together() throws IOException { } @Test - public void shouldRefuseOpenApiNullableWithJackson3() throws IOException { - File output = Files.createTempDirectory("test").toFile().getCanonicalFile(); - output.deleteOnExit(); - - final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/petstore.yaml"); - final KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen(); - codegen.setOpenAPI(openAPI); - codegen.setOutputDir(output.getAbsolutePath()); - - codegen.additionalProperties().put(KotlinSpringServerCodegen.USE_SPRING_BOOT4, "true"); - codegen.additionalProperties().put(AbstractKotlinCodegen.USE_JACKSON_3, "true"); - codegen.additionalProperties().put("openApiNullable", "true"); - - ClientOptInput input = new ClientOptInput(); - input.openAPI(openAPI); - input.config(codegen); - - DefaultGenerator generator = new DefaultGenerator(); - generator.opts(input); - - Assertions.assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(generator::generate); + public void shouldAllowOpenApiNullableWithJackson3() throws IOException { + // jackson-databind-nullable >= 0.2.10 supports both Jackson 2 and 3, + // so openApiNullable + useJackson3 should no longer throw. + Map props = new HashMap<>(); + props.put(KotlinSpringServerCodegen.USE_SPRING_BOOT4, "true"); + props.put(AbstractKotlinCodegen.USE_JACKSON_3, "true"); + props.put(CodegenConstants.OPENAPI_NULLABLE, "true"); + Map files = generateFromContract( + "src/test/resources/3_0/kotlin/required-nullable-4-states.yaml", props); + Assert.assertTrue(files.containsKey("TestModel.kt"), "TestModel.kt should be generated"); } @Test @@ -6118,4 +6106,160 @@ public void testSealedResponseInterfacesWithDeclarativeHttpInterface() throws IO "fun getUser(", "): ResponseEntity"); } + + // ========== REQUIRED + NULLABLE 4-STATE TESTS ========== + + /** + * Scenario 1: required=true, nullable=false + * Expected: non-nullable type, no default value, @JsonProperty(required=true). + */ + @Test(description = "Scenario 1 – required+non-nullable: strict non-nullable property with no default") + public void requiredNullable_scenario1_requiredNonNullable() throws IOException { + Map files = generateFromContract( + "src/test/resources/3_0/kotlin/required-nullable-4-states.yaml", + new HashMap<>()); + + Path modelFile = files.get("TestModel.kt").toPath(); + // Must be non-nullable type (no '?'), must have @JsonProperty(required=true), must have no default + assertFileContains(modelFile, + "@get:JsonProperty(\"requiredNonNullable\", required = true) val requiredNonNullable: kotlin.String"); + // Must NOT have a nullable marker or default value + assertFileNotContains(modelFile, "val requiredNonNullable: kotlin.String?"); + assertFileNotContains(modelFile, "val requiredNonNullable: kotlin.String = "); + } + + /** + * Scenario 2: required=true, nullable=true + * Expected: nullable type, no default value, @JsonProperty(required=true). + */ + @Test(description = "Scenario 2 – required+nullable: nullable type enforced by Jackson required=true") + public void requiredNullable_scenario2_requiredNullable() throws IOException { + Map files = generateFromContract( + "src/test/resources/3_0/kotlin/required-nullable-4-states.yaml", + new HashMap<>()); + + Path modelFile = files.get("TestModel.kt").toPath(); + // Must be nullable type with @JsonProperty(required=true), no default value + assertFileContains(modelFile, + "@get:JsonProperty(\"requiredNullable\", required = true) val requiredNullable: kotlin.String?"); + // Must NOT have a default value + assertFileNotContains(modelFile, "val requiredNullable: kotlin.String? = "); + } + + /** + * Scenario 3: required=false, nullable=false + * Expected: nullable type with null default, AND @field:JsonSetter(nulls=Nulls.FAIL) to block explicit nulls. + */ + @Test(description = "Scenario 3 – optional+non-nullable: null default with JsonSetter FAIL to block explicit nulls") + public void requiredNullable_scenario3_optionalNonNullable() throws IOException { + Map files = generateFromContract( + "src/test/resources/3_0/kotlin/required-nullable-4-states.yaml", + new HashMap<>()); + + Path modelFile = files.get("TestModel.kt").toPath(); + // Must have @field:JsonSetter(nulls = Nulls.FAIL) annotation + assertFileContains(modelFile, "@field:JsonSetter(nulls = Nulls.FAIL)"); + // Must have JsonSetter and Nulls imports + assertFileContains(modelFile, + "import com.fasterxml.jackson.annotation.JsonSetter", + "import com.fasterxml.jackson.annotation.Nulls"); + // Must be nullable type with null default + assertFileContains(modelFile, "val optionalNonNullable: kotlin.String? = null"); + // Must NOT be JsonNullable + assertFileNotContains(modelFile, "JsonNullable"); + } + + /** + * Scenario 4 (openApiNullable=false, default): required=false, nullable=true + * Without openApiNullable, falls back to nullable type with null default (same as before this feature). + */ + @Test(description = "Scenario 4 – optional+nullable without openApiNullable: nullable type with null default (legacy fallback)") + public void requiredNullable_scenario4_optionalNullable_withoutOpenApiNullable() throws IOException { + Map files = generateFromContract( + "src/test/resources/3_0/kotlin/required-nullable-4-states.yaml", + new HashMap<>()); + + Path modelFile = files.get("TestModel.kt").toPath(); + // Without openApiNullable, should still be Type? = null (legacy behavior preserved) + assertFileContains(modelFile, "val optionalNullable: kotlin.String? = null"); + // Must NOT have JsonNullable wrapping + assertFileNotContains(modelFile, "JsonNullable"); + // Must NOT have @field:JsonSetter on nullable optional (only non-nullable gets it) + // (check that the line itself does not have JsonSetter) + String content = Files.readString(modelFile); + int idx = content.indexOf("val optionalNullable:"); + Assert.assertTrue(idx >= 0, "optionalNullable property must exist"); + String context = content.substring(Math.max(0, idx - 100), idx); + Assert.assertFalse(context.contains("@field:JsonSetter"), + "optionalNullable should not have @field:JsonSetter when nullable=true"); + } + + /** + * Scenario 4 (openApiNullable=true): required=false, nullable=true + * Expected: JsonNullable<T> wrapper with JsonNullable.undefined() default. + */ + @Test(description = "Scenario 4 – optional+nullable with openApiNullable=true: JsonNullable 3-state wrapper") + public void requiredNullable_scenario4_optionalNullable_withOpenApiNullable() throws IOException { + Map files = generateFromContract( + "src/test/resources/3_0/kotlin/required-nullable-4-states.yaml", + Map.of(CodegenConstants.OPENAPI_NULLABLE, "true")); + + Path modelFile = files.get("TestModel.kt").toPath(); + // Must use JsonNullable wrapper + assertFileContains(modelFile, "JsonNullable"); + // Must default to JsonNullable.undefined() + assertFileContains(modelFile, "= JsonNullable.undefined()"); + // Must have JsonNullable import + assertFileContains(modelFile, "import org.openapitools.jackson.nullable.JsonNullable"); + // Must NOT be a plain nullable type + assertFileNotContains(modelFile, "val optionalNullable: kotlin.String? = null"); + } + + /** + * Scenario 3 with Jackson 3 (Spring Boot 4): optional + non-nullable. + * @JsonSetter / Nulls imports should come from tools.jackson.annotation. + */ + @Test(description = "Scenario 3 with Jackson 3: tools.jackson.annotation.JsonSetter + Nulls imports") + public void requiredNullable_scenario3_optionalNonNullable_withJackson3() throws IOException { + Map props = new HashMap<>(); + props.put(KotlinSpringServerCodegen.USE_SPRING_BOOT4, "true"); + + Map files = generateFromContract( + "src/test/resources/3_0/kotlin/required-nullable-4-states.yaml", props); + + Path modelFile = files.get("TestModel.kt").toPath(); + // Annotation must still be rendered + assertFileContains(modelFile, "@field:JsonSetter(nulls = Nulls.FAIL)"); + // Imports must come from tools.jackson (Jackson 3 package) + assertFileContains(modelFile, + "import tools.jackson.annotation.JsonSetter", + "import tools.jackson.annotation.Nulls"); + // Must be nullable type with null default + assertFileContains(modelFile, "val optionalNonNullable: kotlin.String? = null"); + } + + /** + * Scenario 4 with Jackson 3 (Spring Boot 4) + openApiNullable=true. + * JsonNullable is in org.openapitools.jackson.nullable regardless of Jackson version + * (jackson-databind-nullable >= 0.2.10 supports both). + */ + @Test(description = "Scenario 4 with Jackson 3 + openApiNullable: JsonNullable works with tools.jackson") + public void requiredNullable_scenario4_optionalNullable_withOpenApiNullable_jackson3() throws IOException { + Map props = new HashMap<>(); + props.put(KotlinSpringServerCodegen.USE_SPRING_BOOT4, "true"); + props.put(CodegenConstants.OPENAPI_NULLABLE, "true"); + + Map files = generateFromContract( + "src/test/resources/3_0/kotlin/required-nullable-4-states.yaml", props); + + Path modelFile = files.get("TestModel.kt").toPath(); + // Must use JsonNullable wrapper + assertFileContains(modelFile, "JsonNullable"); + // Must default to JsonNullable.undefined() + assertFileContains(modelFile, "= JsonNullable.undefined()"); + // org.openapitools.jackson.nullable package is the same for Jackson 2 and 3 + assertFileContains(modelFile, "import org.openapitools.jackson.nullable.JsonNullable"); + // Must NOT be a plain nullable type + assertFileNotContains(modelFile, "val optionalNullable: kotlin.String? = null"); + } } diff --git a/modules/openapi-generator/src/test/resources/3_0/kotlin/required-nullable-4-states.yaml b/modules/openapi-generator/src/test/resources/3_0/kotlin/required-nullable-4-states.yaml new file mode 100644 index 000000000000..345bc97420b2 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/kotlin/required-nullable-4-states.yaml @@ -0,0 +1,40 @@ +openapi: 3.0.0 +info: + title: Required and Nullable 4-State Test + version: 1.0.0 +paths: + /test: + post: + operationId: testPost + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TestModel' + responses: + '200': + description: OK +components: + schemas: + TestModel: + type: object + required: + - requiredNonNullable + - requiredNullable + properties: + # Scenario 1: required=true, nullable=false => strict, non-nullable, no default + requiredNonNullable: + type: string + nullable: false + # Scenario 2: required=true, nullable=true => required but explicit null allowed + requiredNullable: + type: string + nullable: true + # Scenario 3: required=false, nullable=false => optional but must block explicit null + optionalNonNullable: + type: string + nullable: false + # Scenario 4: required=false, nullable=true => 3-state (JsonNullable) + optionalNullable: + type: string + nullable: true From 54c3aa9b29681af241ff870009b4a6f31b7f0e53 Mon Sep 17 00:00:00 2001 From: Jachym Metlicka Date: Sun, 17 May 2026 15:45:45 +0200 Subject: [PATCH 2/9] feat(kotlin): add support for OpenAPI Jackson Nullable library to handle optional and nullable properties --- .../kotlin-spring-boot-sort-validation.yaml | 1 + .../languages/KotlinSpringServerCodegen.java | 5 - .../libraries/spring-boot/pom-sb3.mustache | 9 +- .../libraries/spring-boot/pom-sb4.mustache | 5 + .../libraries/spring-boot/pom.mustache | 5 + .../springBootApplication.mustache | 12 +- .../libraries/spring-cloud/pom-sb3.mustache | 5 + .../libraries/spring-cloud/pom-sb4.mustache | 5 + .../libraries/spring-cloud/pom.mustache | 5 + .../pom-sb3.mustache | 5 + .../pom-sb4.mustache | 5 + .../3_0/spring/petstore-sort-validation.yaml | 78 ++++++++ .../build.gradle.kts | 1 + .../oneOf-discriminator-const/pom.xml | 10 +- .../oneOf-discriminator/build.gradle.kts | 1 + .../oneOf-discriminator/pom.xml | 10 +- .../kotlin/org/openapitools/model/Animal.kt | 2 + .../org/openapitools/model/AnotherAnimal.kt | 2 + .../kotlin/org/openapitools/model/Bird.kt | 4 + .../kotlin/org/openapitools/model/Robobird.kt | 4 + .../oneOf-enum-discriminator/build.gradle.kts | 1 + .../oneOf-enum-discriminator/pom.xml | 10 +- .../kotlin-spring-cloud/build.gradle.kts | 1 + .../petstore/kotlin-spring-cloud/pom.xml | 5 + .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../pom.xml | 5 + .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../pom.xml | 5 + .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../pom.xml | 5 + .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../pom.xml | 5 + .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../kotlin-spring-default/build.gradle.kts | 1 + .../petstore/kotlin-spring-default/pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../org/openapitools/model/Annotation.kt | 3 + .../org/openapitools/model/AnyOfUserOrPet.kt | 12 ++ .../model/AnyOfUserOrPetOrArrayString.kt | 12 ++ .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 9 + .../org/openapitools/model/UserOrPet.kt | 2 + .../model/UserOrPetOrArrayString.kt | 2 + .../build.gradle.kts | 1 + .../kotlin-spring-sealed-interfaces/pom.xml | 10 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../build.gradle.kts | 1 + .../pom.xml | 10 +- .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../kotlin-springboot-3/build.gradle.kts | 1 + .../petstore/kotlin-springboot-3/pom.xml | 10 +- .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../kotlin-springboot-4/build.gradle.kts | 1 + .../petstore/kotlin-springboot-4/pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../build.gradle.kts | 1 + .../pom.xml | 10 +- .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../build.gradle.kts | 1 + .../pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../main/kotlin/org/openapitools/model/Apa.kt | 4 + .../build.gradle.kts | 1 + .../pom.xml | 10 +- .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../build.gradle.kts | 1 + .../kotlin-springboot-delegate/pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../build.gradle.kts | 1 + .../pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../main/kotlin/org/openapitools/model/Cat.kt | 8 + .../kotlin/org/openapitools/model/Category.kt | 4 + .../main/kotlin/org/openapitools/model/Dog.kt | 6 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 2 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../build.gradle.kts | 1 + .../kotlin-springboot-integer-enum/pom.xml | 10 +- .../kotlin/org/openapitools/model/ApiError.kt | 3 + .../build.gradle.kts | 1 + .../kotlin-springboot-modelMutable/pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../build.gradle.kts | 1 + .../pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../model/MultipartMixedRequestMarker.kt | 3 + .../build.gradle.kts | 1 + .../pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../build.gradle.kts | 1 + .../pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../build.gradle.kts | 1 + .../kotlin-springboot-paged-model/pom.xml | 10 +- .../kotlin/org/openapitools/model/Order.kt | 4 + .../main/kotlin/org/openapitools/model/Pet.kt | 4 + .../org/openapitools/model/SearchResult.kt | 5 + .../kotlin/org/openapitools/model/User.kt | 4 + .../kotlin/org/openapitools/model/UserList.kt | 4 + .../build.gradle.kts | 1 + .../pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../build.gradle.kts | 1 + .../kotlin-springboot-reactive/pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../build.gradle.kts | 1 + .../kotlin-springboot-request-cookie/pom.xml | 10 +- .../kotlin/org/openapitools/model/Animal.kt | 2 + .../main/kotlin/org/openapitools/model/Cat.kt | 4 + .../kotlin/org/openapitools/model/Category.kt | 3 + .../kotlin/org/openapitools/model/Client.kt | 3 + .../main/kotlin/org/openapitools/model/Dog.kt | 4 + .../main/kotlin/org/openapitools/model/Foo.kt | 3 + .../model/FooGetDefaultResponse.kt | 3 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../.openapi-generator/FILES | 2 + .../build.gradle.kts | 1 + .../kotlin-springboot-sort-validation/pom.xml | 14 +- .../kotlin/org/openapitools/Application.kt | 12 +- .../org/openapitools/api/NullableApi.kt | 82 ++++++++ .../org/openapitools/api/NullableApiImpl.kt | 83 ++++++++ .../org/openapitools/model/NullableModel.kt | 41 ++++ .../main/kotlin/org/openapitools/model/Pet.kt | 4 + .../api/NullableApiValidationTest.kt | 123 ++++++++++++ .../build.gradle.kts | 1 + .../kotlin-springboot-source-swagger1/pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../build.gradle.kts | 1 + .../kotlin-springboot-source-swagger2/pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../build.gradle.kts | 1 + .../pom.xml | 6 + .../main/kotlin/org/openapitools/model/Cat.kt | 8 + .../kotlin/org/openapitools/model/Category.kt | 4 + .../main/kotlin/org/openapitools/model/Dog.kt | 6 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 2 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../kotlin-springboot/build.gradle.kts | 1 + .../server/petstore/kotlin-springboot/pom.xml | 6 + .../kotlin/org/openapitools/Application.kt | 3 +- .../kotlin/org/openapitools/model/Category.kt | 4 + .../openapitools/model/ModelApiResponse.kt | 5 + .../kotlin/org/openapitools/model/Order.kt | 8 + .../main/kotlin/org/openapitools/model/Pet.kt | 6 + .../main/kotlin/org/openapitools/model/Tag.kt | 4 + .../kotlin/org/openapitools/model/User.kt | 10 + .../.openapi-generator/FILES | 3 + .../org/openapitools/api/NullableApi.java | 79 ++++++++ .../api/NullableApiController.java | 45 +++++ .../org/openapitools/model/NullableModel.java | 180 ++++++++++++++++++ .../src/main/resources/openapi.yaml | 91 +++++++++ 273 files changed, 2152 insertions(+), 53 deletions(-) create mode 100644 samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/api/NullableApi.kt create mode 100644 samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/api/NullableApiImpl.kt create mode 100644 samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/model/NullableModel.kt create mode 100644 samples/server/petstore/kotlin-springboot-sort-validation/src/test/kotlin/org/openapitools/api/NullableApiValidationTest.kt create mode 100644 samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/api/NullableApi.java create mode 100644 samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/api/NullableApiController.java create mode 100644 samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/model/NullableModel.java diff --git a/bin/configs/kotlin-spring-boot-sort-validation.yaml b/bin/configs/kotlin-spring-boot-sort-validation.yaml index 6f543e0cf4d5..485233c40fad 100644 --- a/bin/configs/kotlin-spring-boot-sort-validation.yaml +++ b/bin/configs/kotlin-spring-boot-sort-validation.yaml @@ -14,5 +14,6 @@ additionalProperties: useSpringBoot3: "true" generateSortValidation: "true" generatePageableConstraintValidation: "true" + openApiNullable: "true" useTags: "true" requestMappingMode: api_interface diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java index 1f6f9e582a18..b3df33a2b61c 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java @@ -1519,11 +1519,6 @@ public ModelsMap postProcessModelsEnum(ModelsMap objs) { // Scenario 4: optional + nullable with openApiNullable → use JsonNullable if (openApiNullable && !var.required && var.isNullable) { var.vendorExtensions.put("x-is-jackson-optional-nullable", true); - if (importMapping.containsKey("JsonNullable")) { - Map item = new HashMap<>(); - item.put("import", importMapping.get("JsonNullable")); - imports.add(item); - } } } } diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb3.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb3.mustache index e48fc8d6772b..6f262b5a481d 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb3.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb3.mustache @@ -13,9 +13,9 @@ 2.2.15{{/swagger2AnnotationLibrary}}{{/springDocDocumentationProvider}} 3.0.2 2.1.0 - 1.7.10 + 1.9.25 - 1.7.10 + 1.9.25 UTF-8 @@ -209,6 +209,11 @@ ${jakarta-annotation.version} provided + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit5 diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb4.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb4.mustache index 1a8d34689c06..004a1a002067 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb4.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom-sb4.mustache @@ -221,5 +221,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom.mustache index b73f2498dfd8..a89f9647c957 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/pom.mustache @@ -202,5 +202,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/springBootApplication.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/springBootApplication.mustache index 3692d6d763f7..7f03ca475c58 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/springBootApplication.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/springBootApplication.mustache @@ -1,12 +1,22 @@ package {{basePackage}} +{{#openApiNullable}} +import com.fasterxml.jackson.databind.Module +import org.openapitools.jackson.nullable.JsonNullableModule +import org.springframework.context.annotation.Bean +{{/openApiNullable}} import org.springframework.boot.runApplication import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["{{basePackage}}", "{{apiPackage}}", "{{modelPackage}}"]) -class Application +class Application { +{{#openApiNullable}} + @Bean(name = ["{{basePackage}}.Application.jsonNullableModule"]) + fun jsonNullableModule(): Module = JsonNullableModule() +{{/openApiNullable}} +} fun main(args: Array) { runApplication(*args) diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb3.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb3.mustache index 791fc9cd40a2..878ae3623302 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb3.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb3.mustache @@ -236,5 +236,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb4.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb4.mustache index ee4ebda17098..4324adc2b447 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb4.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom-sb4.mustache @@ -242,5 +242,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom.mustache index 47fb42f7ae55..762cbdb4f451 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-cloud/pom.mustache @@ -219,5 +219,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/pom-sb3.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/pom-sb3.mustache index f4a6053d110f..12f17944301f 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/pom-sb3.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/pom-sb3.mustache @@ -226,5 +226,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/pom-sb4.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/pom-sb4.mustache index 4ce93ab8e4dd..99cd33f187e8 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/pom-sb4.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-declarative-http-interface/pom-sb4.mustache @@ -232,5 +232,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + \ No newline at end of file diff --git a/modules/openapi-generator/src/test/resources/3_0/spring/petstore-sort-validation.yaml b/modules/openapi-generator/src/test/resources/3_0/spring/petstore-sort-validation.yaml index 86d398d2c407..dcfa3797c804 100644 --- a/modules/openapi-generator/src/test/resources/3_0/spring/petstore-sort-validation.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/spring/petstore-sort-validation.yaml @@ -540,8 +540,86 @@ paths: type: array items: $ref: '#/components/schemas/Pet' + # ---- openApiNullable / 4-state required×nullable test cases ---- + + /nullable/check-required-only: + post: + tags: + - nullable + summary: POST with only required fields — impl asserts optional fields are absent/undefined + operationId: checkRequiredOnly + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/NullableModel' + responses: + '200': + description: OK — assertions in impl passed + '400': + description: Bad request + + /nullable/check-optional-nullable-null: + post: + tags: + - nullable + summary: POST with optionalNullable set to null — impl asserts JsonNullable is present-with-null + operationId: checkOptionalNullableNull + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/NullableModel' + responses: + '200': + description: OK — assertions in impl passed + '400': + description: Bad request + + /nullable/check-all-present: + post: + tags: + - nullable + summary: POST with all 4 fields present — impl asserts each field has the expected value + operationId: checkAllPresent + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/NullableModel' + responses: + '200': + description: OK — assertions in impl passed + '400': + description: Bad request + components: schemas: + NullableModel: + type: object + required: + - requiredNonNullable + - requiredNullable + properties: + # Scenario 1: required=true, nullable=false => strict, non-nullable + requiredNonNullable: + type: string + nullable: false + # Scenario 2: required=true, nullable=true => required but explicit null allowed + requiredNullable: + type: string + nullable: true + # Scenario 3: required=false, nullable=false => @JsonSetter(nulls=FAIL) blocks explicit null + optionalNonNullable: + type: string + nullable: false + # Scenario 4: required=false, nullable=true => JsonNullable (absent/null/value) + optionalNullable: + type: string + nullable: true PetSort: type: string enum: diff --git a/samples/server/others/kotlin-springboot/oneOf-discriminator-const/build.gradle.kts b/samples/server/others/kotlin-springboot/oneOf-discriminator-const/build.gradle.kts index dff0fa211c8d..30b6a49c9bf6 100644 --- a/samples/server/others/kotlin-springboot/oneOf-discriminator-const/build.gradle.kts +++ b/samples/server/others/kotlin-springboot/oneOf-discriminator-const/build.gradle.kts @@ -39,6 +39,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api") + implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/samples/server/others/kotlin-springboot/oneOf-discriminator-const/pom.xml b/samples/server/others/kotlin-springboot/oneOf-discriminator-const/pom.xml index 70890ca131cc..c83b8a04b7ef 100644 --- a/samples/server/others/kotlin-springboot/oneOf-discriminator-const/pom.xml +++ b/samples/server/others/kotlin-springboot/oneOf-discriminator-const/pom.xml @@ -8,9 +8,9 @@ 3.0.2 2.1.0 - 1.7.10 + 1.9.25 - 1.7.10 + 1.9.25 UTF-8 @@ -136,12 +136,18 @@ org.springframework.boot spring-boot-starter-validation + jakarta.annotation jakarta.annotation-api ${jakarta-annotation.version} provided + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit5 diff --git a/samples/server/others/kotlin-springboot/oneOf-discriminator/build.gradle.kts b/samples/server/others/kotlin-springboot/oneOf-discriminator/build.gradle.kts index dff0fa211c8d..30b6a49c9bf6 100644 --- a/samples/server/others/kotlin-springboot/oneOf-discriminator/build.gradle.kts +++ b/samples/server/others/kotlin-springboot/oneOf-discriminator/build.gradle.kts @@ -39,6 +39,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api") + implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/samples/server/others/kotlin-springboot/oneOf-discriminator/pom.xml b/samples/server/others/kotlin-springboot/oneOf-discriminator/pom.xml index 70890ca131cc..c83b8a04b7ef 100644 --- a/samples/server/others/kotlin-springboot/oneOf-discriminator/pom.xml +++ b/samples/server/others/kotlin-springboot/oneOf-discriminator/pom.xml @@ -8,9 +8,9 @@ 3.0.2 2.1.0 - 1.7.10 + 1.9.25 - 1.7.10 + 1.9.25 UTF-8 @@ -136,12 +136,18 @@ org.springframework.boot spring-boot-starter-validation + jakarta.annotation jakarta.annotation-api ${jakarta-annotation.version} provided + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit5 diff --git a/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/Animal.kt b/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/Animal.kt index cd4ca70bbd76..02f4480dff16 100644 --- a/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/Animal.kt +++ b/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/Animal.kt @@ -3,8 +3,10 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonSubTypes import com.fasterxml.jackson.annotation.JsonTypeInfo +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Bird import org.openapitools.model.Robobird import jakarta.validation.constraints.DecimalMax diff --git a/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/AnotherAnimal.kt b/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/AnotherAnimal.kt index 2c04b66ba59f..79141421f051 100644 --- a/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/AnotherAnimal.kt +++ b/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/AnotherAnimal.kt @@ -3,8 +3,10 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonSubTypes import com.fasterxml.jackson.annotation.JsonTypeInfo +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Bird import org.openapitools.model.Robobird import jakarta.validation.constraints.DecimalMax diff --git a/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/Bird.kt b/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/Bird.kt index fb121eeee588..8dbaf1af4835 100644 --- a/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/Bird.kt +++ b/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/Bird.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonSubTypes import com.fasterxml.jackson.annotation.JsonTypeInfo @@ -28,8 +30,10 @@ data class Bird( @get:JsonProperty("another_discriminator", required = true) override val anotherDiscriminator: kotlin.String = "ANOTHER_BIRD", + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("propertyA") val propertyA: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("sameNameProperty") val sameNameProperty: kotlin.Int? = null ) : Animal, AnotherAnimal { diff --git a/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/Robobird.kt b/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/Robobird.kt index 98e06b9b617f..84beafa032ff 100644 --- a/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/Robobird.kt +++ b/samples/server/others/kotlin-springboot/oneOf-discriminator/src/main/kotlin/org/openapitools/model/Robobird.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonSubTypes import com.fasterxml.jackson.annotation.JsonTypeInfo @@ -28,8 +30,10 @@ data class Robobird( @get:JsonProperty("another_discriminator", required = true) override val anotherDiscriminator: kotlin.String = "ANOTHER_ROBOBIRD", + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("propertyB") val propertyB: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("sameNameProperty") val sameNameProperty: kotlin.String? = null ) : Animal, AnotherAnimal { diff --git a/samples/server/others/kotlin-springboot/oneOf-enum-discriminator/build.gradle.kts b/samples/server/others/kotlin-springboot/oneOf-enum-discriminator/build.gradle.kts index dff0fa211c8d..30b6a49c9bf6 100644 --- a/samples/server/others/kotlin-springboot/oneOf-enum-discriminator/build.gradle.kts +++ b/samples/server/others/kotlin-springboot/oneOf-enum-discriminator/build.gradle.kts @@ -39,6 +39,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api") + implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/samples/server/others/kotlin-springboot/oneOf-enum-discriminator/pom.xml b/samples/server/others/kotlin-springboot/oneOf-enum-discriminator/pom.xml index 70890ca131cc..c83b8a04b7ef 100644 --- a/samples/server/others/kotlin-springboot/oneOf-enum-discriminator/pom.xml +++ b/samples/server/others/kotlin-springboot/oneOf-enum-discriminator/pom.xml @@ -8,9 +8,9 @@ 3.0.2 2.1.0 - 1.7.10 + 1.9.25 - 1.7.10 + 1.9.25 UTF-8 @@ -136,12 +136,18 @@ org.springframework.boot spring-boot-starter-validation + jakarta.annotation jakarta.annotation-api ${jakarta-annotation.version} provided + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit5 diff --git a/samples/server/petstore/kotlin-spring-cloud/build.gradle.kts b/samples/server/petstore/kotlin-spring-cloud/build.gradle.kts index ac2381f20ab6..bc3fe797d8cc 100644 --- a/samples/server/petstore/kotlin-spring-cloud/build.gradle.kts +++ b/samples/server/petstore/kotlin-spring-cloud/build.gradle.kts @@ -58,6 +58,7 @@ dependencies { implementation("org.springframework.cloud:spring-cloud-starter-oauth2:2.2.5.RELEASE") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") } diff --git a/samples/server/petstore/kotlin-spring-cloud/pom.xml b/samples/server/petstore/kotlin-spring-cloud/pom.xml index a6b6639f7a3a..a1d6b801b802 100644 --- a/samples/server/petstore/kotlin-spring-cloud/pom.xml +++ b/samples/server/petstore/kotlin-spring-cloud/pom.xml @@ -146,5 +146,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Category.kt index be44647ad001..ca3f8ceb65a9 100644 --- a/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -19,9 +21,11 @@ import javax.validation.Valid */ data class Category( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 8e01881b9571..7618278dd799 100644 --- a/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -20,10 +22,13 @@ import javax.validation.Valid */ data class ModelApiResponse( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Order.kt index 3837fc6822be..f8819a1b18e2 100644 --- a/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -25,16 +27,22 @@ import javax.validation.Valid */ data class Order( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Pet.kt index 142ad86789b1..37e0689e58c3 100644 --- a/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import javax.validation.constraints.DecimalMax @@ -31,15 +33,19 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Tag.kt index 5f31c1eea428..0d5a6c4648ca 100644 --- a/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -19,8 +21,10 @@ import javax.validation.Valid */ data class Tag( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/User.kt index 07f4aa9cf2c1..517f05a5c709 100644 --- a/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-spring-cloud/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -25,20 +27,28 @@ import javax.validation.Valid */ data class User( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/pom.xml b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/pom.xml index 8d80f1de11dc..4158c380a4ac 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/pom.xml +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/pom.xml @@ -173,5 +173,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Category.kt index b7b5e059c976..07967fff45f0 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -21,10 +23,12 @@ import io.swagger.v3.oas.annotations.media.Schema data class Category( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 394c0098f8f0..46a6dc2eae84 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.v3.oas.annotations.media.Schema data class ModelApiResponse( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Order.kt index 4749b654be89..715c0fee45d8 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.v3.oas.annotations.media.Schema data class Order( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @Schema(example = "null", description = "Order Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Pet.kt index b5645e48a282..f0a7a8bb6017 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import jakarta.validation.constraints.DecimalMax @@ -35,18 +37,22 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Schema(example = "null", description = "pet status in the store") @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Tag.kt index fbcd6bc6890a..321a45dc7b7f 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Tag( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/User.kt index 2ab37ba8ae92..0d1f073cf0a0 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-coroutines/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.v3.oas.annotations.media.Schema data class User( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/pom.xml b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/pom.xml index 8d80f1de11dc..4158c380a4ac 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/pom.xml +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/pom.xml @@ -173,5 +173,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Category.kt index b7b5e059c976..07967fff45f0 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -21,10 +23,12 @@ import io.swagger.v3.oas.annotations.media.Schema data class Category( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 394c0098f8f0..46a6dc2eae84 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.v3.oas.annotations.media.Schema data class ModelApiResponse( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Order.kt index 4749b654be89..715c0fee45d8 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.v3.oas.annotations.media.Schema data class Order( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @Schema(example = "null", description = "Order Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Pet.kt index b5645e48a282..f0a7a8bb6017 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import jakarta.validation.constraints.DecimalMax @@ -35,18 +37,22 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Schema(example = "null", description = "pet status in the store") @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Tag.kt index fbcd6bc6890a..321a45dc7b7f 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Tag( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/User.kt index 2ab37ba8ae92..0d1f073cf0a0 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-reactive-reactor-wrapped/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.v3.oas.annotations.media.Schema data class User( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/pom.xml b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/pom.xml index 15416bbf0ea7..a524f024dfc0 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/pom.xml +++ b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/pom.xml @@ -161,5 +161,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Category.kt index b7b5e059c976..07967fff45f0 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -21,10 +23,12 @@ import io.swagger.v3.oas.annotations.media.Schema data class Category( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 394c0098f8f0..46a6dc2eae84 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.v3.oas.annotations.media.Schema data class ModelApiResponse( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Order.kt index 4749b654be89..715c0fee45d8 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.v3.oas.annotations.media.Schema data class Order( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @Schema(example = "null", description = "Order Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Pet.kt index b5645e48a282..f0a7a8bb6017 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import jakarta.validation.constraints.DecimalMax @@ -35,18 +37,22 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Schema(example = "null", description = "pet status in the store") @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Tag.kt index fbcd6bc6890a..321a45dc7b7f 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Tag( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/User.kt index 2ab37ba8ae92..0d1f073cf0a0 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface-wrapped/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.v3.oas.annotations.media.Schema data class User( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface/pom.xml b/samples/server/petstore/kotlin-spring-declarative-interface/pom.xml index 15416bbf0ea7..a524f024dfc0 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface/pom.xml +++ b/samples/server/petstore/kotlin-spring-declarative-interface/pom.xml @@ -161,5 +161,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Category.kt index b7b5e059c976..07967fff45f0 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -21,10 +23,12 @@ import io.swagger.v3.oas.annotations.media.Schema data class Category( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 394c0098f8f0..46a6dc2eae84 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.v3.oas.annotations.media.Schema data class ModelApiResponse( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Order.kt index 4749b654be89..715c0fee45d8 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.v3.oas.annotations.media.Schema data class Order( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @Schema(example = "null", description = "Order Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Pet.kt index b5645e48a282..f0a7a8bb6017 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import jakarta.validation.constraints.DecimalMax @@ -35,18 +37,22 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Schema(example = "null", description = "pet status in the store") @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Tag.kt index fbcd6bc6890a..321a45dc7b7f 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Tag( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/User.kt index 2ab37ba8ae92..0d1f073cf0a0 100644 --- a/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-spring-declarative-interface/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.v3.oas.annotations.media.Schema data class User( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-spring-default/build.gradle.kts b/samples/server/petstore/kotlin-spring-default/build.gradle.kts index 3b564eb0a224..1511d04ff777 100644 --- a/samples/server/petstore/kotlin-spring-default/build.gradle.kts +++ b/samples/server/petstore/kotlin-spring-default/build.gradle.kts @@ -43,6 +43,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-spring-default/pom.xml b/samples/server/petstore/kotlin-spring-default/pom.xml index 3266249b3379..51ee394c70b6 100644 --- a/samples/server/petstore/kotlin-spring-default/pom.xml +++ b/samples/server/petstore/kotlin-spring-default/pom.xml @@ -129,6 +129,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -141,5 +142,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Annotation.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Annotation.kt index 4aff423b3adc..dbd94dbc7049 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Annotation.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Annotation.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -20,6 +22,7 @@ import io.swagger.v3.oas.annotations.media.Schema data class Annotation( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: java.util.UUID? = null ) { diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/AnyOfUserOrPet.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/AnyOfUserOrPet.kt index 317d5386108e..2ac072129d73 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/AnyOfUserOrPet.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/AnyOfUserOrPet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Pet import org.openapitools.model.Tag @@ -47,36 +49,46 @@ data class AnyOfUserOrPet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Schema(example = "null", description = "pet status in the store") @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: AnyOfUserOrPet.Status? = null ) { diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/AnyOfUserOrPetOrArrayString.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/AnyOfUserOrPetOrArrayString.kt index 03df455663f1..fc7a28a02d0d 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/AnyOfUserOrPetOrArrayString.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/AnyOfUserOrPetOrArrayString.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Pet import org.openapitools.model.Tag @@ -47,36 +49,46 @@ data class AnyOfUserOrPetOrArrayString( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Schema(example = "null", description = "pet status in the store") @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: AnyOfUserOrPetOrArrayString.Status? = null ) { diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Category.kt index 64541c666d41..facc07134f56 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,10 +23,12 @@ import io.swagger.v3.oas.annotations.media.Schema data class Category( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 6af39346cf4c..f58f23e7598f 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.v3.oas.annotations.media.Schema data class ModelApiResponse( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Order.kt index 9e29b16a1d27..83f2628de198 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.v3.oas.annotations.media.Schema data class Order( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @Schema(example = "null", description = "Order Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) { diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Pet.kt index c491482d5d14..e0f3913e9259 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import javax.validation.constraints.DecimalMax @@ -35,18 +37,22 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Schema(example = "null", description = "pet status in the store") @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : UserOrPet, UserOrPetOrArrayString { diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Tag.kt index 0f2b45edcf7c..b212ce890669 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Tag( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/User.kt index ec6d754415d8..6fdaee387140 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonValue import javax.validation.constraints.DecimalMax @@ -32,24 +34,31 @@ data class User( @get:JsonProperty("username", required = true) val username: kotlin.String, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : UserOrPet, UserOrPetOrArrayString { diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/UserOrPet.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/UserOrPet.kt index c337b9d447ac..561cb29a10bb 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/UserOrPet.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/UserOrPet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Pet import org.openapitools.model.Tag diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/UserOrPetOrArrayString.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/UserOrPetOrArrayString.kt index e94b3aee8c38..21b795f8afa9 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/UserOrPetOrArrayString.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/model/UserOrPetOrArrayString.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Pet import org.openapitools.model.Tag diff --git a/samples/server/petstore/kotlin-spring-sealed-interfaces/build.gradle.kts b/samples/server/petstore/kotlin-spring-sealed-interfaces/build.gradle.kts index dff0fa211c8d..30b6a49c9bf6 100644 --- a/samples/server/petstore/kotlin-spring-sealed-interfaces/build.gradle.kts +++ b/samples/server/petstore/kotlin-spring-sealed-interfaces/build.gradle.kts @@ -39,6 +39,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api") + implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/samples/server/petstore/kotlin-spring-sealed-interfaces/pom.xml b/samples/server/petstore/kotlin-spring-sealed-interfaces/pom.xml index 70890ca131cc..c83b8a04b7ef 100644 --- a/samples/server/petstore/kotlin-spring-sealed-interfaces/pom.xml +++ b/samples/server/petstore/kotlin-spring-sealed-interfaces/pom.xml @@ -8,9 +8,9 @@ 3.0.2 2.1.0 - 1.7.10 + 1.9.25 - 1.7.10 + 1.9.25 UTF-8 @@ -136,12 +136,18 @@ org.springframework.boot spring-boot-starter-validation + jakarta.annotation jakarta.annotation-api ${jakarta-annotation.version} provided + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit5 diff --git a/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Category.kt index 3cc63c511b1b..ea40bb2c965f 100644 --- a/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -19,9 +21,11 @@ import jakarta.validation.Valid */ data class Category( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 0abe67b0e8b1..7103b6cafec1 100644 --- a/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -20,10 +22,13 @@ import jakarta.validation.Valid */ data class ModelApiResponse( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Order.kt index 23b812a1c833..9f5e9a70e069 100644 --- a/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.PlaceOrderResponse import org.openapitools.model.GetOrderByIdResponse import jakarta.validation.constraints.DecimalMax @@ -27,16 +29,22 @@ import jakarta.validation.Valid */ data class Order( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : PlaceOrderResponse, GetOrderByIdResponse { diff --git a/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Pet.kt index 2b982141d636..44bea7571691 100644 --- a/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import org.openapitools.model.UpdatePetResponse @@ -34,15 +36,19 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : UpdatePetResponse, AddPetResponse, GetPetByIdResponse { diff --git a/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Tag.kt index c1081aeaf97c..8ac0ee0bf487 100644 --- a/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -19,8 +21,10 @@ import jakarta.validation.Valid */ data class Tag( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/User.kt index 154bac03e3a0..c8caeb1b6dc0 100644 --- a/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-spring-sealed-interfaces/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.GetUserByNameResponse import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin @@ -26,20 +28,28 @@ import jakarta.validation.Valid */ data class User( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : GetUserByNameResponse { diff --git a/samples/server/petstore/kotlin-springboot-3-no-response-entity/build.gradle.kts b/samples/server/petstore/kotlin-springboot-3-no-response-entity/build.gradle.kts index 40bf9b2e8598..4da27eaa665a 100644 --- a/samples/server/petstore/kotlin-springboot-3-no-response-entity/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-3-no-response-entity/build.gradle.kts @@ -35,6 +35,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api") + implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/samples/server/petstore/kotlin-springboot-3-no-response-entity/pom.xml b/samples/server/petstore/kotlin-springboot-3-no-response-entity/pom.xml index ff3dce2609d7..19d8c4b2bcac 100644 --- a/samples/server/petstore/kotlin-springboot-3-no-response-entity/pom.xml +++ b/samples/server/petstore/kotlin-springboot-3-no-response-entity/pom.xml @@ -8,9 +8,9 @@ 3.0.2 2.1.0 - 1.7.10 + 1.9.25 - 1.7.10 + 1.9.25 UTF-8 @@ -136,12 +136,18 @@ org.springframework.boot spring-boot-starter-validation + jakarta.annotation jakarta.annotation-api ${jakarta-annotation.version} provided + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit5 diff --git a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Category.kt index 8dd57ffa6660..a21009655d77 100644 --- a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -19,9 +21,11 @@ import jakarta.validation.Valid */ data class Category( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index fdf1b18bd73a..b0ca34c2fa9e 100644 --- a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -20,10 +22,13 @@ import jakarta.validation.Valid */ data class ModelApiResponse( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Order.kt index 89e7b2a343bf..7dcae28c0485 100644 --- a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -25,16 +27,22 @@ import jakarta.validation.Valid */ data class Order( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Pet.kt index ecd6a3004900..fb6a4ba5a866 100644 --- a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import jakarta.validation.constraints.DecimalMax @@ -31,15 +33,19 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Tag.kt index 371a5b122269..a5a0baad98c8 100644 --- a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -19,8 +21,10 @@ import jakarta.validation.Valid */ data class Tag( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/User.kt index 2172272f1c0c..409a68510ec0 100644 --- a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -25,20 +27,28 @@ import jakarta.validation.Valid */ data class User( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-3/build.gradle.kts b/samples/server/petstore/kotlin-springboot-3/build.gradle.kts index 40bf9b2e8598..4da27eaa665a 100644 --- a/samples/server/petstore/kotlin-springboot-3/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-3/build.gradle.kts @@ -35,6 +35,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api") + implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/samples/server/petstore/kotlin-springboot-3/pom.xml b/samples/server/petstore/kotlin-springboot-3/pom.xml index ff3dce2609d7..19d8c4b2bcac 100644 --- a/samples/server/petstore/kotlin-springboot-3/pom.xml +++ b/samples/server/petstore/kotlin-springboot-3/pom.xml @@ -8,9 +8,9 @@ 3.0.2 2.1.0 - 1.7.10 + 1.9.25 - 1.7.10 + 1.9.25 UTF-8 @@ -136,12 +136,18 @@ org.springframework.boot spring-boot-starter-validation + jakarta.annotation jakarta.annotation-api ${jakarta-annotation.version} provided + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit5 diff --git a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Category.kt index 8dd57ffa6660..a21009655d77 100644 --- a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -19,9 +21,11 @@ import jakarta.validation.Valid */ data class Category( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index fdf1b18bd73a..b0ca34c2fa9e 100644 --- a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -20,10 +22,13 @@ import jakarta.validation.Valid */ data class ModelApiResponse( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Order.kt index 89e7b2a343bf..7dcae28c0485 100644 --- a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -25,16 +27,22 @@ import jakarta.validation.Valid */ data class Order( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Pet.kt index ecd6a3004900..fb6a4ba5a866 100644 --- a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import jakarta.validation.constraints.DecimalMax @@ -31,15 +33,19 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Tag.kt index 371a5b122269..a5a0baad98c8 100644 --- a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -19,8 +21,10 @@ import jakarta.validation.Valid */ data class Tag( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/User.kt index 2172272f1c0c..409a68510ec0 100644 --- a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -25,20 +27,28 @@ import jakarta.validation.Valid */ data class User( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-4/build.gradle.kts b/samples/server/petstore/kotlin-springboot-4/build.gradle.kts index 74cd0aa87c40..89cec4382133 100644 --- a/samples/server/petstore/kotlin-springboot-4/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-4/build.gradle.kts @@ -36,6 +36,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api") + implementation("jakarta.annotation:jakarta.annotation-api:3.0.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/samples/server/petstore/kotlin-springboot-4/pom.xml b/samples/server/petstore/kotlin-springboot-4/pom.xml index 9ea4ab03f32e..956c82ac2c0d 100644 --- a/samples/server/petstore/kotlin-springboot-4/pom.xml +++ b/samples/server/petstore/kotlin-springboot-4/pom.xml @@ -123,6 +123,7 @@ org.springframework.boot spring-boot-starter-validation + jakarta.annotation jakarta.annotation-api @@ -135,5 +136,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + \ No newline at end of file diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Category.kt index 8dd57ffa6660..606e55e5466a 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import tools.jackson.annotation.JsonSetter +import tools.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -19,9 +21,11 @@ import jakarta.validation.Valid */ data class Category( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index fdf1b18bd73a..186af830f366 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import tools.jackson.annotation.JsonSetter +import tools.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -20,10 +22,13 @@ import jakarta.validation.Valid */ data class ModelApiResponse( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Order.kt index 89e7b2a343bf..8dc477d7fea9 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Order.kt @@ -4,6 +4,8 @@ import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonValue +import tools.jackson.annotation.JsonSetter +import tools.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -25,16 +27,22 @@ import jakarta.validation.Valid */ data class Order( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Pet.kt index ecd6a3004900..c6a8c67b131e 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Pet.kt @@ -6,6 +6,8 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonValue import org.openapitools.model.Category import org.openapitools.model.Tag +import tools.jackson.annotation.JsonSetter +import tools.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -31,15 +33,19 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Tag.kt index 371a5b122269..cd79877cd5b9 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import tools.jackson.annotation.JsonSetter +import tools.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -19,8 +21,10 @@ import jakarta.validation.Valid */ data class Tag( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/User.kt index 2172272f1c0c..856b11893340 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import tools.jackson.annotation.JsonSetter +import tools.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -25,20 +27,28 @@ import jakarta.validation.Valid */ data class User( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-additionalproperties/build.gradle.kts b/samples/server/petstore/kotlin-springboot-additionalproperties/build.gradle.kts index 40bf9b2e8598..4da27eaa665a 100644 --- a/samples/server/petstore/kotlin-springboot-additionalproperties/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-additionalproperties/build.gradle.kts @@ -35,6 +35,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api") + implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/samples/server/petstore/kotlin-springboot-additionalproperties/pom.xml b/samples/server/petstore/kotlin-springboot-additionalproperties/pom.xml index ff3dce2609d7..19d8c4b2bcac 100644 --- a/samples/server/petstore/kotlin-springboot-additionalproperties/pom.xml +++ b/samples/server/petstore/kotlin-springboot-additionalproperties/pom.xml @@ -8,9 +8,9 @@ 3.0.2 2.1.0 - 1.7.10 + 1.9.25 - 1.7.10 + 1.9.25 UTF-8 @@ -136,12 +136,18 @@ org.springframework.boot spring-boot-starter-validation + jakarta.annotation jakarta.annotation-api ${jakarta-annotation.version} provided + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit5 diff --git a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Category.kt index 8dd57ffa6660..a21009655d77 100644 --- a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -19,9 +21,11 @@ import jakarta.validation.Valid */ data class Category( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index fdf1b18bd73a..b0ca34c2fa9e 100644 --- a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -20,10 +22,13 @@ import jakarta.validation.Valid */ data class ModelApiResponse( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Order.kt index 89e7b2a343bf..7dcae28c0485 100644 --- a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -25,16 +27,22 @@ import jakarta.validation.Valid */ data class Order( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Pet.kt index ec96343526db..03ea024df173 100644 --- a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import jakarta.validation.constraints.DecimalMax @@ -31,15 +33,19 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : kotlin.collections.HashMap(), java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Tag.kt index 371a5b122269..a5a0baad98c8 100644 --- a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -19,8 +21,10 @@ import jakarta.validation.Valid */ data class Tag( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/User.kt index 2172272f1c0c..409a68510ec0 100644 --- a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -25,20 +27,28 @@ import jakarta.validation.Valid */ data class User( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-bigdecimal-default/build.gradle.kts b/samples/server/petstore/kotlin-springboot-bigdecimal-default/build.gradle.kts index 3b564eb0a224..1511d04ff777 100644 --- a/samples/server/petstore/kotlin-springboot-bigdecimal-default/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-bigdecimal-default/build.gradle.kts @@ -43,6 +43,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-springboot-bigdecimal-default/pom.xml b/samples/server/petstore/kotlin-springboot-bigdecimal-default/pom.xml index 3266249b3379..51ee394c70b6 100644 --- a/samples/server/petstore/kotlin-springboot-bigdecimal-default/pom.xml +++ b/samples/server/petstore/kotlin-springboot-bigdecimal-default/pom.xml @@ -129,6 +129,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -141,5 +142,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-springboot-bigdecimal-default/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-bigdecimal-default/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-bigdecimal-default/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-bigdecimal-default/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-bigdecimal-default/src/main/kotlin/org/openapitools/model/Apa.kt b/samples/server/petstore/kotlin-springboot-bigdecimal-default/src/main/kotlin/org/openapitools/model/Apa.kt index 9742503f4748..bbe9a05bda0e 100644 --- a/samples/server/petstore/kotlin-springboot-bigdecimal-default/src/main/kotlin/org/openapitools/model/Apa.kt +++ b/samples/server/petstore/kotlin-springboot-bigdecimal-default/src/main/kotlin/org/openapitools/model/Apa.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -31,9 +33,11 @@ data class Apa( @get:JsonProperty("cepa", required = true) val cepa: java.math.BigDecimal = java.math.BigDecimal("6.28318"), @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("depa") val depa: java.math.BigDecimal? = java.math.BigDecimal("71"), @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("epa") val epa: java.math.BigDecimal? = java.math.BigDecimal("-71"), @Schema(example = "null", description = "") diff --git a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/build.gradle.kts b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/build.gradle.kts index 6d11299c6962..b72e5d89ced6 100644 --- a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/build.gradle.kts @@ -36,6 +36,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api") + implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/pom.xml b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/pom.xml index d147fbc3aced..0171f1fd140e 100644 --- a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/pom.xml +++ b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/pom.xml @@ -9,9 +9,9 @@ 2.2.15 3.0.2 2.1.0 - 1.7.10 + 1.9.25 - 1.7.10 + 1.9.25 UTF-8 @@ -142,12 +142,18 @@ org.springframework.boot spring-boot-starter-validation + jakarta.annotation jakarta.annotation-api ${jakarta-annotation.version} provided + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit5 diff --git a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Category.kt index 615e56c9b85a..0a593d726463 100644 --- a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -21,10 +23,12 @@ import io.swagger.v3.oas.annotations.media.Schema data class Category( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 338a2d0f46ec..abe7e2e0af5c 100644 --- a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.v3.oas.annotations.media.Schema data class ModelApiResponse( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Order.kt index 421fba2bc288..3efc155f0902 100644 --- a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.v3.oas.annotations.media.Schema data class Order( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @Schema(example = "null", description = "Order Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) { diff --git a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Pet.kt index 6c697505209a..b7d6097268cc 100644 --- a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import jakarta.validation.constraints.DecimalMax @@ -35,18 +37,22 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Schema(example = "null", description = "pet status in the store") @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Tag.kt index a4357f8358e3..8d528d428882 100644 --- a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Tag( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/User.kt index 74a1c1056afc..bee8b756bc1b 100644 --- a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.v3.oas.annotations.media.Schema data class User( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-delegate/build.gradle.kts b/samples/server/petstore/kotlin-springboot-delegate/build.gradle.kts index 3b564eb0a224..1511d04ff777 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-delegate/build.gradle.kts @@ -43,6 +43,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-springboot-delegate/pom.xml b/samples/server/petstore/kotlin-springboot-delegate/pom.xml index 3266249b3379..51ee394c70b6 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/pom.xml +++ b/samples/server/petstore/kotlin-springboot-delegate/pom.xml @@ -129,6 +129,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -141,5 +142,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Category.kt index 64541c666d41..facc07134f56 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,10 +23,12 @@ import io.swagger.v3.oas.annotations.media.Schema data class Category( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 6af39346cf4c..f58f23e7598f 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.v3.oas.annotations.media.Schema data class ModelApiResponse( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Order.kt index 9e29b16a1d27..83f2628de198 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.v3.oas.annotations.media.Schema data class Order( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @Schema(example = "null", description = "Order Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) { diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Pet.kt index bf7fe3ba7e30..ec30cdcdbc5f 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import javax.validation.constraints.DecimalMax @@ -35,18 +37,22 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Schema(example = "null", description = "pet status in the store") @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Tag.kt index 0f2b45edcf7c..b212ce890669 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Tag( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/User.kt index ef3d46afd3e2..0e055e0afe02 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.v3.oas.annotations.media.Schema data class User( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/build.gradle.kts b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/build.gradle.kts index 0f622040f5d6..af5e78ffffb4 100644 --- a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/build.gradle.kts @@ -46,6 +46,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/pom.xml b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/pom.xml index a8e82b9771f9..0832be1ac805 100644 --- a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/pom.xml +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/pom.xml @@ -140,6 +140,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -152,5 +153,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Cat.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Cat.kt index 0a473c42c892..9c4d77f6a75e 100644 --- a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Cat.kt +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Cat.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Color import org.openapitools.model.Pet @@ -43,24 +45,30 @@ data class Cat( @get:JsonProperty("petType", required = true) override val petType: kotlin.String, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("hunts") val hunts: kotlin.Boolean? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("age") val age: kotlin.Int? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") override val id: kotlin.Long? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") override val category: Category? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") override val tags: kotlin.collections.List? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("color") override val color: Color? = null ) : Pet, java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Category.kt index 88ad6599859e..c5e4ce253a87 100644 --- a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.annotations.ApiModelProperty data class Category( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Dog.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Dog.kt index 5f78da36f834..302fa2eff7d4 100644 --- a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Dog.kt +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Dog.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Color import org.openapitools.model.Pet @@ -53,18 +55,22 @@ data class Dog( @get:JsonProperty("petType", required = true) override val petType: kotlin.String, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") override val id: kotlin.Long? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") override val category: Category? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") override val tags: kotlin.collections.List? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("color") override val color: Color? = null ) : Pet, com.some.pack.Fetchable, java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 7cfb2ea3091b..22a9a7ea7618 100644 --- a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.annotations.ApiModelProperty data class ModelApiResponse( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Order.kt index 59ff0e5d49cf..1dc7672da598 100644 --- a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.annotations.ApiModelProperty data class Order( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Pet.kt index b84896b73529..bad6273edeec 100644 --- a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Pet.kt @@ -4,9 +4,11 @@ import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonSubTypes import com.fasterxml.jackson.annotation.JsonTypeInfo import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Color import org.openapitools.model.Tag diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Tag.kt index 94ca9b340ad4..636157b0d44f 100644 --- a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.annotations.ApiModelProperty data class Tag( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/User.kt index 0012d176ce14..7247f2eb5aa3 100644 --- a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.annotations.ApiModelProperty data class User( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-integer-enum/build.gradle.kts b/samples/server/petstore/kotlin-springboot-integer-enum/build.gradle.kts index dff0fa211c8d..30b6a49c9bf6 100644 --- a/samples/server/petstore/kotlin-springboot-integer-enum/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-integer-enum/build.gradle.kts @@ -39,6 +39,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api") + implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/samples/server/petstore/kotlin-springboot-integer-enum/pom.xml b/samples/server/petstore/kotlin-springboot-integer-enum/pom.xml index 70890ca131cc..c83b8a04b7ef 100644 --- a/samples/server/petstore/kotlin-springboot-integer-enum/pom.xml +++ b/samples/server/petstore/kotlin-springboot-integer-enum/pom.xml @@ -8,9 +8,9 @@ 3.0.2 2.1.0 - 1.7.10 + 1.9.25 - 1.7.10 + 1.9.25 UTF-8 @@ -136,12 +136,18 @@ org.springframework.boot spring-boot-starter-validation + jakarta.annotation jakarta.annotation-api ${jakarta-annotation.version} provided + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit5 diff --git a/samples/server/petstore/kotlin-springboot-integer-enum/src/main/kotlin/org/openapitools/model/ApiError.kt b/samples/server/petstore/kotlin-springboot-integer-enum/src/main/kotlin/org/openapitools/model/ApiError.kt index fc9125438859..2afc11e52eea 100644 --- a/samples/server/petstore/kotlin-springboot-integer-enum/src/main/kotlin/org/openapitools/model/ApiError.kt +++ b/samples/server/petstore/kotlin-springboot-integer-enum/src/main/kotlin/org/openapitools/model/ApiError.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.ReasonCode import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin @@ -25,6 +27,7 @@ data class ApiError( @get:JsonProperty("errorCode", required = true) val errorCode: ApiError.ErrorCode, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("reasonCode") val reasonCode: ReasonCode? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-modelMutable/build.gradle.kts b/samples/server/petstore/kotlin-springboot-modelMutable/build.gradle.kts index 3b564eb0a224..1511d04ff777 100644 --- a/samples/server/petstore/kotlin-springboot-modelMutable/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-modelMutable/build.gradle.kts @@ -43,6 +43,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-springboot-modelMutable/pom.xml b/samples/server/petstore/kotlin-springboot-modelMutable/pom.xml index 3266249b3379..51ee394c70b6 100644 --- a/samples/server/petstore/kotlin-springboot-modelMutable/pom.xml +++ b/samples/server/petstore/kotlin-springboot-modelMutable/pom.xml @@ -129,6 +129,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -141,5 +142,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Category.kt index 564ad968bb2e..a72f52efe412 100644 --- a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Category( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") var id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") var name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index d9b7e8098583..e1f321bd27ea 100644 --- a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.v3.oas.annotations.media.Schema data class ModelApiResponse( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") var code: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") var type: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") var message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Order.kt index bb277f934a55..00a939158c1e 100644 --- a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.v3.oas.annotations.media.Schema data class Order( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") var id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") var petId: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") var quantity: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") var shipDate: java.time.OffsetDateTime? = null, @Schema(example = "null", description = "Order Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") var status: Order.Status? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") var complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Pet.kt index f3b940591d40..101a0d5bdb27 100644 --- a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import javax.validation.constraints.DecimalMax @@ -35,17 +37,21 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) var photoUrls: kotlin.collections.MutableList, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") var id: kotlin.Long? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") var category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") var tags: kotlin.collections.MutableList? = null, @Schema(example = "null", description = "pet status in the store") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") var status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Tag.kt index 90aec37872e8..51be056ab949 100644 --- a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Tag( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") var id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") var name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/User.kt index b157be763a0c..387e42af9c98 100644 --- a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.v3.oas.annotations.media.Schema data class User( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") var id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") var username: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") var firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") var lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") var email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") var password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") var phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") var userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-multipart-request-model/build.gradle.kts b/samples/server/petstore/kotlin-springboot-multipart-request-model/build.gradle.kts index 3b564eb0a224..1511d04ff777 100644 --- a/samples/server/petstore/kotlin-springboot-multipart-request-model/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-multipart-request-model/build.gradle.kts @@ -43,6 +43,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-springboot-multipart-request-model/pom.xml b/samples/server/petstore/kotlin-springboot-multipart-request-model/pom.xml index 3266249b3379..51ee394c70b6 100644 --- a/samples/server/petstore/kotlin-springboot-multipart-request-model/pom.xml +++ b/samples/server/petstore/kotlin-springboot-multipart-request-model/pom.xml @@ -129,6 +129,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -141,5 +142,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-springboot-multipart-request-model/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-multipart-request-model/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-multipart-request-model/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-multipart-request-model/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-multipart-request-model/src/main/kotlin/org/openapitools/model/MultipartMixedRequestMarker.kt b/samples/server/petstore/kotlin-springboot-multipart-request-model/src/main/kotlin/org/openapitools/model/MultipartMixedRequestMarker.kt index 1a8f989c9174..aa14da7376a3 100644 --- a/samples/server/petstore/kotlin-springboot-multipart-request-model/src/main/kotlin/org/openapitools/model/MultipartMixedRequestMarker.kt +++ b/samples/server/petstore/kotlin-springboot-multipart-request-model/src/main/kotlin/org/openapitools/model/MultipartMixedRequestMarker.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -20,6 +22,7 @@ import io.swagger.v3.oas.annotations.media.Schema data class MultipartMixedRequestMarker( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/build.gradle.kts b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/build.gradle.kts index 7dcfd792a49e..9e9df5e59bdd 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/build.gradle.kts @@ -42,6 +42,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/pom.xml b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/pom.xml index 37342a0b679b..e41846212fae 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/pom.xml +++ b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/pom.xml @@ -123,6 +123,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -135,5 +136,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Category.kt index 936b664977b3..9bfdc156868c 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -19,8 +21,10 @@ import javax.validation.Valid */ data class Category( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 8e01881b9571..7618278dd799 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -20,10 +22,13 @@ import javax.validation.Valid */ data class ModelApiResponse( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Order.kt index 3837fc6822be..f8819a1b18e2 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -25,16 +27,22 @@ import javax.validation.Valid */ data class Order( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Pet.kt index 6bf5e554c941..ec6985af729e 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import javax.validation.constraints.DecimalMax @@ -31,14 +33,18 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Tag.kt index 5f31c1eea428..0d5a6c4648ca 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -19,8 +21,10 @@ import javax.validation.Valid */ data class Tag( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/User.kt index 07f4aa9cf2c1..517f05a5c709 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -25,20 +27,28 @@ import javax.validation.Valid */ data class User( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity/build.gradle.kts b/samples/server/petstore/kotlin-springboot-no-response-entity/build.gradle.kts index 7dcfd792a49e..9e9df5e59bdd 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-no-response-entity/build.gradle.kts @@ -42,6 +42,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity/pom.xml b/samples/server/petstore/kotlin-springboot-no-response-entity/pom.xml index 37342a0b679b..e41846212fae 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity/pom.xml +++ b/samples/server/petstore/kotlin-springboot-no-response-entity/pom.xml @@ -123,6 +123,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -135,5 +136,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Category.kt index 936b664977b3..9bfdc156868c 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -19,8 +21,10 @@ import javax.validation.Valid */ data class Category( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 8e01881b9571..7618278dd799 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -20,10 +22,13 @@ import javax.validation.Valid */ data class ModelApiResponse( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Order.kt index 3837fc6822be..f8819a1b18e2 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -25,16 +27,22 @@ import javax.validation.Valid */ data class Order( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Pet.kt index 6bf5e554c941..ec6985af729e 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import javax.validation.constraints.DecimalMax @@ -31,14 +33,18 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Tag.kt index 5f31c1eea428..0d5a6c4648ca 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -19,8 +21,10 @@ import javax.validation.Valid */ data class Tag( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/User.kt index 07f4aa9cf2c1..517f05a5c709 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -25,20 +27,28 @@ import javax.validation.Valid */ data class User( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-paged-model/build.gradle.kts b/samples/server/petstore/kotlin-springboot-paged-model/build.gradle.kts index dff0fa211c8d..30b6a49c9bf6 100644 --- a/samples/server/petstore/kotlin-springboot-paged-model/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-paged-model/build.gradle.kts @@ -39,6 +39,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api") + implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/samples/server/petstore/kotlin-springboot-paged-model/pom.xml b/samples/server/petstore/kotlin-springboot-paged-model/pom.xml index 70890ca131cc..c83b8a04b7ef 100644 --- a/samples/server/petstore/kotlin-springboot-paged-model/pom.xml +++ b/samples/server/petstore/kotlin-springboot-paged-model/pom.xml @@ -8,9 +8,9 @@ 3.0.2 2.1.0 - 1.7.10 + 1.9.25 - 1.7.10 + 1.9.25 UTF-8 @@ -136,12 +136,18 @@ org.springframework.boot spring-boot-starter-validation + jakarta.annotation jakarta.annotation-api ${jakarta-annotation.version} provided + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit5 diff --git a/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/Order.kt index 33d8605449f9..64e80ed513ab 100644 --- a/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/Order.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -19,8 +21,10 @@ import jakarta.validation.Valid */ data class Order( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("amount") val amount: kotlin.Double? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/Pet.kt index cd363ed97c14..0b1a09f06d4b 100644 --- a/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/Pet.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -22,8 +24,10 @@ data class Pet( @get:JsonProperty("name", required = true) val name: kotlin.String, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/SearchResult.kt b/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/SearchResult.kt index 05ba6402f637..585eb9083623 100644 --- a/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/SearchResult.kt +++ b/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/SearchResult.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.PageMeta import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin @@ -21,11 +23,14 @@ import jakarta.validation.Valid */ data class SearchResult( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("query") val query: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("totalHits") val totalHits: kotlin.Int? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("page") val page: PageMeta? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/User.kt index 9a0442128083..48dd074b73c4 100644 --- a/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -19,8 +21,10 @@ import jakarta.validation.Valid */ data class User( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/UserList.kt b/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/UserList.kt index 61457585fe74..870f3ccc62cc 100644 --- a/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/UserList.kt +++ b/samples/server/petstore/kotlin-springboot-paged-model/src/main/kotlin/org/openapitools/model/UserList.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.User import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin @@ -21,8 +23,10 @@ import jakarta.validation.Valid data class UserList( @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("content") val content: kotlin.collections.List? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("description") val description: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-reactive-without-flow/build.gradle.kts b/samples/server/petstore/kotlin-springboot-reactive-without-flow/build.gradle.kts index 9294e90a715a..d41e7c6cee1e 100644 --- a/samples/server/petstore/kotlin-springboot-reactive-without-flow/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-reactive-without-flow/build.gradle.kts @@ -46,6 +46,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-springboot-reactive-without-flow/pom.xml b/samples/server/petstore/kotlin-springboot-reactive-without-flow/pom.xml index d0e993868ac5..3eec599d0c42 100644 --- a/samples/server/petstore/kotlin-springboot-reactive-without-flow/pom.xml +++ b/samples/server/petstore/kotlin-springboot-reactive-without-flow/pom.xml @@ -140,6 +140,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -152,5 +153,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Category.kt index 64541c666d41..facc07134f56 100644 --- a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,10 +23,12 @@ import io.swagger.v3.oas.annotations.media.Schema data class Category( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 6af39346cf4c..f58f23e7598f 100644 --- a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.v3.oas.annotations.media.Schema data class ModelApiResponse( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Order.kt index 9e29b16a1d27..83f2628de198 100644 --- a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.v3.oas.annotations.media.Schema data class Order( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @Schema(example = "null", description = "Order Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) { diff --git a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Pet.kt index bf7fe3ba7e30..ec30cdcdbc5f 100644 --- a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import javax.validation.constraints.DecimalMax @@ -35,18 +37,22 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Schema(example = "null", description = "pet status in the store") @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Tag.kt index 0f2b45edcf7c..b212ce890669 100644 --- a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Tag( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/User.kt index ef3d46afd3e2..0e055e0afe02 100644 --- a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.v3.oas.annotations.media.Schema data class User( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-reactive/build.gradle.kts b/samples/server/petstore/kotlin-springboot-reactive/build.gradle.kts index 9294e90a715a..d41e7c6cee1e 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-reactive/build.gradle.kts @@ -46,6 +46,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-springboot-reactive/pom.xml b/samples/server/petstore/kotlin-springboot-reactive/pom.xml index d0e993868ac5..3eec599d0c42 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/pom.xml +++ b/samples/server/petstore/kotlin-springboot-reactive/pom.xml @@ -140,6 +140,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -152,5 +153,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Category.kt index 64541c666d41..facc07134f56 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,10 +23,12 @@ import io.swagger.v3.oas.annotations.media.Schema data class Category( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 6af39346cf4c..f58f23e7598f 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.v3.oas.annotations.media.Schema data class ModelApiResponse( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Order.kt index 9e29b16a1d27..83f2628de198 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.v3.oas.annotations.media.Schema data class Order( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @Schema(example = "null", description = "Order Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) { diff --git a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Pet.kt index bf7fe3ba7e30..ec30cdcdbc5f 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import javax.validation.constraints.DecimalMax @@ -35,18 +37,22 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Schema(example = "null", description = "pet status in the store") @Deprecated(message = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Tag.kt index 0f2b45edcf7c..b212ce890669 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Tag( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/User.kt index ef3d46afd3e2..0e055e0afe02 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.v3.oas.annotations.media.Schema data class User( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/build.gradle.kts b/samples/server/petstore/kotlin-springboot-request-cookie/build.gradle.kts index 8b6393c0f390..e817ff561503 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-request-cookie/build.gradle.kts @@ -40,6 +40,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api") + implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/pom.xml b/samples/server/petstore/kotlin-springboot-request-cookie/pom.xml index 938995f0a711..977ef6f7ff00 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/pom.xml +++ b/samples/server/petstore/kotlin-springboot-request-cookie/pom.xml @@ -9,9 +9,9 @@ 2.2.0 3.0.2 2.1.0 - 1.7.10 + 1.9.25 - 1.7.10 + 1.9.25 UTF-8 @@ -142,12 +142,18 @@ org.springframework.boot spring-boot-starter-validation + jakarta.annotation jakarta.annotation-api ${jakarta-annotation.version} provided + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit5 diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Animal.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Animal.kt index d426653fe02d..00138b93b051 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Animal.kt +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Animal.kt @@ -3,8 +3,10 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonSubTypes import com.fasterxml.jackson.annotation.JsonTypeInfo +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Cat.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Cat.kt index 7ff41fa0b477..5854bb80a826 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Cat.kt +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Cat.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Animal import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin @@ -26,9 +28,11 @@ data class Cat( @get:JsonProperty("className", required = true) override val className: kotlin.String, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("declawed") val declawed: kotlin.Boolean? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("color") override val color: kotlin.String? = "red" ) : Animal { diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Category.kt index 161bd3a22eb6..ba33804e09a1 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -24,6 +26,7 @@ data class Category( @get:JsonProperty("name", required = true) val name: kotlin.String = "default-name", @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Client.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Client.kt index cd3652ce6d4c..76cbe1780459 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Client.kt +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Client.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -20,6 +22,7 @@ import io.swagger.v3.oas.annotations.media.Schema data class Client( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("client") val client: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Dog.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Dog.kt index 883bf9c5d6b8..1399efc90acb 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Dog.kt +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Dog.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Animal import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin @@ -26,9 +28,11 @@ data class Dog( @get:JsonProperty("className", required = true) override val className: kotlin.String, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("breed") val breed: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("color") override val color: kotlin.String? = "red" ) : Animal { diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Foo.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Foo.kt index 6139b8105518..2f48b3ba7270 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Foo.kt +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Foo.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -20,6 +22,7 @@ import io.swagger.v3.oas.annotations.media.Schema data class Foo( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("bar") val bar: kotlin.String? = "bar" ) { diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/FooGetDefaultResponse.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/FooGetDefaultResponse.kt index 0a0b15e5bcce..79280b896909 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/FooGetDefaultResponse.kt +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/FooGetDefaultResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Foo import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin @@ -22,6 +24,7 @@ data class FooGetDefaultResponse( @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("string") val string: Foo? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index d4a1ed7c31fa..6e611bfde3f9 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.v3.oas.annotations.media.Schema data class ModelApiResponse( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Order.kt index bfa82f37b53e..7107f5dde4aa 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.v3.oas.annotations.media.Schema data class Order( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @Schema(example = "null", description = "Order Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) { diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Pet.kt index b7fafeffcd87..94deeafe5d75 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import jakarta.validation.constraints.DecimalMax @@ -35,17 +37,21 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.Set, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Schema(example = "null", description = "pet status in the store") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Tag.kt index 6f2021de260f..5432f8a1fe94 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Tag( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/User.kt index 7150e5308178..10ceb48e183c 100644 --- a/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-request-cookie/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.v3.oas.annotations.media.Schema data class User( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) { diff --git a/samples/server/petstore/kotlin-springboot-sort-validation/.openapi-generator/FILES b/samples/server/petstore/kotlin-springboot-sort-validation/.openapi-generator/FILES index 90a2baceec60..dfb5385de94b 100644 --- a/samples/server/petstore/kotlin-springboot-sort-validation/.openapi-generator/FILES +++ b/samples/server/petstore/kotlin-springboot-sort-validation/.openapi-generator/FILES @@ -8,10 +8,12 @@ pom.xml settings.gradle src/main/kotlin/org/openapitools/api/ApiUtil.kt src/main/kotlin/org/openapitools/api/Exceptions.kt +src/main/kotlin/org/openapitools/api/NullableApi.kt src/main/kotlin/org/openapitools/api/PetApi.kt src/main/kotlin/org/openapitools/configuration/EnumConverterConfiguration.kt src/main/kotlin/org/openapitools/configuration/ValidPageable.kt src/main/kotlin/org/openapitools/configuration/ValidSort.kt +src/main/kotlin/org/openapitools/model/NullableModel.kt src/main/kotlin/org/openapitools/model/Pet.kt src/main/kotlin/org/openapitools/model/PetSort.kt src/main/kotlin/org/openapitools/model/PetSortEnum.kt diff --git a/samples/server/petstore/kotlin-springboot-sort-validation/build.gradle.kts b/samples/server/petstore/kotlin-springboot-sort-validation/build.gradle.kts index dff0fa211c8d..02b51e955849 100644 --- a/samples/server/petstore/kotlin-springboot-sort-validation/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-sort-validation/build.gradle.kts @@ -39,6 +39,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("jakarta.validation:jakarta.validation-api") + implementation("org.openapitools:jackson-databind-nullable:0.2.10") implementation("jakarta.annotation:jakarta.annotation-api:2.1.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") diff --git a/samples/server/petstore/kotlin-springboot-sort-validation/pom.xml b/samples/server/petstore/kotlin-springboot-sort-validation/pom.xml index 70890ca131cc..3784896e920b 100644 --- a/samples/server/petstore/kotlin-springboot-sort-validation/pom.xml +++ b/samples/server/petstore/kotlin-springboot-sort-validation/pom.xml @@ -8,9 +8,9 @@ 3.0.2 2.1.0 - 1.7.10 + 1.9.25 - 1.7.10 + 1.9.25 UTF-8 @@ -136,12 +136,22 @@ org.springframework.boot spring-boot-starter-validation + + org.openapitools + jackson-databind-nullable + 0.2.10 + jakarta.annotation jakarta.annotation-api ${jakarta-annotation.version} provided + + org.springframework.boot + spring-boot-starter-test + test + org.jetbrains.kotlin kotlin-test-junit5 diff --git a/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/Application.kt index 411871b327af..4023b6a2bfc9 100644 --- a/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/Application.kt @@ -1,12 +1,18 @@ package org.openapitools -import org.springframework.boot.autoconfigure.SpringBootApplication +import com.fasterxml.jackson.databind.Module +import org.openapitools.jackson.nullable.JsonNullableModule +import org.springframework.context.annotation.Bean import org.springframework.boot.runApplication +import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.ComponentScan @SpringBootApplication -@ComponentScan("org.openapitools") -class Application +@ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) +class Application { + @Bean(name = ["org.openapitools.Application.jsonNullableModule"]) + fun jsonNullableModule(): Module = JsonNullableModule() +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/api/NullableApi.kt b/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/api/NullableApi.kt new file mode 100644 index 000000000000..ce61e974b5fe --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/api/NullableApi.kt @@ -0,0 +1,82 @@ +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.23.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. +*/ +package org.openapitools.api + +import org.openapitools.model.NullableModel +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity + +import org.springframework.web.bind.annotation.* +import org.springframework.validation.annotation.Validated +import org.springframework.web.context.request.NativeWebRequest +import org.springframework.beans.factory.annotation.Autowired + +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +import kotlin.collections.List +import kotlin.collections.Map + +@RestController +@Validated +@RequestMapping("\${api.base-path:/v2}") +interface NullableApi { + + + @RequestMapping( + method = [RequestMethod.POST], + // "/nullable/check-all-present" + value = [PATH_CHECK_ALL_PRESENT], + consumes = ["application/json"] + ) + fun checkAllPresent( + @Valid @RequestBody nullableModel: NullableModel + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.POST], + // "/nullable/check-optional-nullable-null" + value = [PATH_CHECK_OPTIONAL_NULLABLE_NULL], + consumes = ["application/json"] + ) + fun checkOptionalNullableNull( + @Valid @RequestBody nullableModel: NullableModel + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + + @RequestMapping( + method = [RequestMethod.POST], + // "/nullable/check-required-only" + value = [PATH_CHECK_REQUIRED_ONLY], + consumes = ["application/json"] + ) + fun checkRequiredOnly( + @Valid @RequestBody nullableModel: NullableModel + ): ResponseEntity { + return ResponseEntity(HttpStatus.NOT_IMPLEMENTED) + } + + companion object { + //for your own safety never directly reuse these path definitions in tests + const val BASE_PATH: String = "/v2" + const val PATH_CHECK_ALL_PRESENT: String = "/nullable/check-all-present" + const val PATH_CHECK_OPTIONAL_NULLABLE_NULL: String = "/nullable/check-optional-nullable-null" + const val PATH_CHECK_REQUIRED_ONLY: String = "/nullable/check-required-only" + } +} diff --git a/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/api/NullableApiImpl.kt b/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/api/NullableApiImpl.kt new file mode 100644 index 000000000000..d1c833f7fcf3 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/api/NullableApiImpl.kt @@ -0,0 +1,83 @@ +package org.openapitools.api + +import org.openapitools.jackson.nullable.JsonNullable +import org.openapitools.model.NullableModel +import org.springframework.http.HttpStatus +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.RestController + +/** + * Sample implementation of [NullableApi] demonstrating that the generated + * openApiNullable annotations work correctly at runtime. + * + * Each method receives a deserialized [NullableModel] and asserts the expected + * state of its fields. When Jackson correctly applies `@field:JsonSetter(nulls = Nulls.FAIL)` + * and `JsonNullable`, the assertions pass and HTTP 200 is returned. If the + * deserialized state is wrong, the assertion throws [IllegalStateException] and + * the request fails with HTTP 500, which causes any calling test to fail. + * + * The null-rejection case (`optionalNonNullable = null` in JSON) never reaches + * a method body — Jackson's `Nulls.FAIL` throws during deserialization, and + * Spring maps the resulting [org.springframework.http.converter.HttpMessageNotReadableException] + * to HTTP 400 before the method is called. + */ +@RestController +class NullableApiImpl : NullableApi { + + /** + * Endpoint for verifying the "required fields only" scenario. + * + * The JSON body contains only the two required fields; both optional fields are absent. + * Expected state: + * - [NullableModel.optionalNonNullable] → `null` (absent key → default null) + * - [NullableModel.optionalNullable] → `JsonNullable.undefined()` (absent key → undefined) + */ + override fun checkRequiredOnly(nullableModel: NullableModel): ResponseEntity { + check(nullableModel.optionalNonNullable == null) { + "optionalNonNullable: expected null (absent from JSON), got ${nullableModel.optionalNonNullable}" + } + check(!nullableModel.optionalNullable.isPresent) { + "optionalNullable: expected JsonNullable.undefined() (absent from JSON), got ${nullableModel.optionalNullable}" + } + return ResponseEntity(HttpStatus.OK) + } + + /** + * Endpoint for verifying the "optional nullable sent as explicit null" scenario. + * + * The JSON body contains the required fields plus `"optionalNullable": null`. + * Expected state: + * - [NullableModel.optionalNullable] → `JsonNullable.of(null)` + * (key present with null value → isPresent = true, get() = null) + */ + override fun checkOptionalNullableNull(nullableModel: NullableModel): ResponseEntity { + check(nullableModel.optionalNullable.isPresent) { + "optionalNullable: expected JsonNullable present (explicit null in JSON), got ${nullableModel.optionalNullable}" + } + check(nullableModel.optionalNullable.get() == null) { + "optionalNullable: expected null inner value, got ${nullableModel.optionalNullable.get()}" + } + return ResponseEntity(HttpStatus.OK) + } + + /** + * Endpoint for verifying the "all four fields present" scenario. + * + * The JSON body contains all four fields with non-null string values. + * Expected state: + * - [NullableModel.optionalNonNullable] → `"opt-non-null"` (plain string) + * - [NullableModel.optionalNullable] → `JsonNullable.of("opt-nullable")` (isPresent, non-null value) + */ + override fun checkAllPresent(nullableModel: NullableModel): ResponseEntity { + check(nullableModel.optionalNonNullable == "opt-non-null") { + "optionalNonNullable: expected 'opt-non-null', got ${nullableModel.optionalNonNullable}" + } + check(nullableModel.optionalNullable.isPresent) { + "optionalNullable: expected JsonNullable present, got ${nullableModel.optionalNullable}" + } + check(nullableModel.optionalNullable.get() == "opt-nullable") { + "optionalNullable: expected 'opt-nullable', got ${nullableModel.optionalNullable.get()}" + } + return ResponseEntity(HttpStatus.OK) + } +} diff --git a/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/model/NullableModel.kt b/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/model/NullableModel.kt new file mode 100644 index 000000000000..f086232ac853 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/model/NullableModel.kt @@ -0,0 +1,41 @@ +package org.openapitools.model + +import java.util.Objects +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls +import org.openapitools.jackson.nullable.JsonNullable +import jakarta.validation.constraints.DecimalMax +import jakarta.validation.constraints.DecimalMin +import jakarta.validation.constraints.Email +import jakarta.validation.constraints.Max +import jakarta.validation.constraints.Min +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size +import jakarta.validation.Valid + +/** + * + * @param requiredNonNullable + * @param requiredNullable + * @param optionalNonNullable + * @param optionalNullable + */ +data class NullableModel( + + @get:JsonProperty("requiredNonNullable", required = true) val requiredNonNullable: kotlin.String, + + @get:JsonProperty("requiredNullable", required = true) val requiredNullable: kotlin.String?, + + @field:JsonSetter(nulls = Nulls.FAIL) + @get:JsonProperty("optionalNonNullable") val optionalNonNullable: kotlin.String? = null, + + @get:JsonProperty("optionalNullable") val optionalNullable: JsonNullable = JsonNullable.undefined() +) : java.io.Serializable { + + companion object { + private const val serialVersionUID: kotlin.Long = 1 + } +} + diff --git a/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/model/Pet.kt index 5e896ae0469b..27c2649c2f6f 100644 --- a/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-sort-validation/src/main/kotlin/org/openapitools/model/Pet.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email @@ -22,8 +24,10 @@ data class Pet( @get:JsonProperty("name", required = true) val name: kotlin.String, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-sort-validation/src/test/kotlin/org/openapitools/api/NullableApiValidationTest.kt b/samples/server/petstore/kotlin-springboot-sort-validation/src/test/kotlin/org/openapitools/api/NullableApiValidationTest.kt new file mode 100644 index 000000000000..e65801037f28 --- /dev/null +++ b/samples/server/petstore/kotlin-springboot-sort-validation/src/test/kotlin/org/openapitools/api/NullableApiValidationTest.kt @@ -0,0 +1,123 @@ +package org.openapitools.api + +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.http.MediaType +import org.springframework.test.web.servlet.MockMvc +import org.springframework.test.web.servlet.post + +/** + * Verifies the runtime behaviour of the openApiNullable annotations generated onto [NullableApi]: + * + * - **`@field:JsonSetter(nulls = Nulls.FAIL)`** on `optionalNonNullable` — sending an explicit JSON + * null for a non-nullable optional field is rejected with HTTP 400 (Jackson fires before the method + * is called; Spring maps `HttpMessageNotReadableException` to 400). + * - **`JsonNullable`** on `optionalNullable` — Jackson correctly distinguishes three states: + * - **absent** (`JsonNullable.undefined()`) when the key is omitted from the JSON body + * - **present-with-null** (`JsonNullable.of(null)`) when `"optionalNullable": null` is sent + * - **present-with-value** (`JsonNullable.of("...")`) when a non-null value is sent + * + * HTTP 200 responses confirm both that the request was accepted *and* that [NullableApiImpl]'s + * internal assertions about the deserialized state passed. + * HTTP 400 responses confirm that Jackson (or bean validation) rejected the invalid input. + */ +@SpringBootTest +@AutoConfigureMockMvc +class NullableApiValidationTest { + + @Autowired + lateinit var mockMvc: MockMvc + + // ── checkRequiredOnly — positive cases ─────────────────────────────────── + // Endpoint: POST /nullable/check-required-only + // Impl asserts: optionalNonNullable == null && !optionalNullable.isPresent + + @Test + fun `checkRequiredOnly - only required fields returns 200 and impl assertions pass`() { + mockMvc.post("${NullableApi.BASE_PATH}${NullableApi.PATH_CHECK_REQUIRED_ONLY}") { + contentType = MediaType.APPLICATION_JSON + content = """{"requiredNonNullable":"foo","requiredNullable":"bar"}""" + }.andExpect { status { isOk() } } + } + + @Test + fun `checkRequiredOnly - requiredNullable sent as explicit null is accepted`() { + // requiredNullable is String? — explicit null is allowed + mockMvc.post("${NullableApi.BASE_PATH}${NullableApi.PATH_CHECK_REQUIRED_ONLY}") { + contentType = MediaType.APPLICATION_JSON + content = """{"requiredNonNullable":"foo","requiredNullable":null}""" + }.andExpect { status { isOk() } } + } + + // ── checkRequiredOnly — null-rejection case ─────────────────────────────── + // @field:JsonSetter(nulls = Nulls.FAIL) on optionalNonNullable blocks explicit null in JSON + + @Test + fun `checkRequiredOnly - optionalNonNullable sent as explicit null returns 400`() { + // Jackson fires Nulls.FAIL before the method body is reached → HttpMessageNotReadableException → 400 + mockMvc.post("${NullableApi.BASE_PATH}${NullableApi.PATH_CHECK_REQUIRED_ONLY}") { + contentType = MediaType.APPLICATION_JSON + content = """{"requiredNonNullable":"foo","requiredNullable":"bar","optionalNonNullable":null}""" + }.andExpect { status { isBadRequest() } } + } + + // ── missing required field → 400 ───────────────────────────────────────── + // Jackson module-kotlin enforces Kotlin non-nullable types → throws on missing required field + + @Test + fun `checkRequiredOnly - missing requiredNonNullable returns 400`() { + mockMvc.post("${NullableApi.BASE_PATH}${NullableApi.PATH_CHECK_REQUIRED_ONLY}") { + contentType = MediaType.APPLICATION_JSON + content = """{"requiredNullable":"bar"}""" + }.andExpect { status { isBadRequest() } } + } + + // ── checkOptionalNullableNull — present-with-null state ────────────────── + // Endpoint: POST /nullable/check-optional-nullable-null + // Impl asserts: optionalNullable.isPresent && optionalNullable.get() == null + + @Test + fun `checkOptionalNullableNull - optionalNullable as explicit null returns 200 and impl assertions pass`() { + mockMvc.post("${NullableApi.BASE_PATH}${NullableApi.PATH_CHECK_OPTIONAL_NULLABLE_NULL}") { + contentType = MediaType.APPLICATION_JSON + content = """{"requiredNonNullable":"foo","requiredNullable":"bar","optionalNullable":null}""" + }.andExpect { status { isOk() } } + } + + // ── checkAllPresent — present-with-value state ─────────────────────────── + // Endpoint: POST /nullable/check-all-present + // Impl asserts: optionalNonNullable == "opt-non-null" && optionalNullable.isPresent && get() == "opt-nullable" + + @Test + fun `checkAllPresent - all four fields with values returns 200 and impl assertions pass`() { + mockMvc.post("${NullableApi.BASE_PATH}${NullableApi.PATH_CHECK_ALL_PRESENT}") { + contentType = MediaType.APPLICATION_JSON + content = """ + { + "requiredNonNullable": "req-non-null", + "requiredNullable": "req-nullable", + "optionalNonNullable": "opt-non-null", + "optionalNullable": "opt-nullable" + } + """.trimIndent() + }.andExpect { status { isOk() } } + } + + @Test + fun `checkAllPresent - optionalNonNullable sent as explicit null returns 400`() { + // Even on a different endpoint, Nulls.FAIL fires before the method body + mockMvc.post("${NullableApi.BASE_PATH}${NullableApi.PATH_CHECK_ALL_PRESENT}") { + contentType = MediaType.APPLICATION_JSON + content = """ + { + "requiredNonNullable": "req-non-null", + "requiredNullable": "req-nullable", + "optionalNonNullable": null, + "optionalNullable": "opt-nullable" + } + """.trimIndent() + }.andExpect { status { isBadRequest() } } + } +} diff --git a/samples/server/petstore/kotlin-springboot-source-swagger1/build.gradle.kts b/samples/server/petstore/kotlin-springboot-source-swagger1/build.gradle.kts index bbf10f687c00..06ca4f1ff775 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger1/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-source-swagger1/build.gradle.kts @@ -45,6 +45,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-springboot-source-swagger1/pom.xml b/samples/server/petstore/kotlin-springboot-source-swagger1/pom.xml index 85b4059abd00..92fe770b729e 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger1/pom.xml +++ b/samples/server/petstore/kotlin-springboot-source-swagger1/pom.xml @@ -139,6 +139,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -151,5 +152,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Category.kt index 072095d92ad6..ac6f42acee61 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.annotations.ApiModelProperty data class Category( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 9a75259a855f..9c1f941f8b9b 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.annotations.ApiModelProperty data class ModelApiResponse( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Order.kt index be36c58d3a54..cd6d207bf7d5 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.annotations.ApiModelProperty data class Order( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @ApiModelProperty(example = "null", value = "Order Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Pet.kt index 006e3b29ac02..59c619dfe330 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import javax.validation.constraints.DecimalMax @@ -35,17 +37,21 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @ApiModelProperty(example = "null", value = "pet status in the store") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Tag.kt index b9d3297258e1..efe28fdb364c 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.annotations.ApiModelProperty data class Tag( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/User.kt index f33aedc5b388..1badf4313715 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.annotations.ApiModelProperty data class User( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @ApiModelProperty(example = "null", value = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-source-swagger2/build.gradle.kts b/samples/server/petstore/kotlin-springboot-source-swagger2/build.gradle.kts index fd5cbc3238f8..b2e29da0de29 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger2/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-source-swagger2/build.gradle.kts @@ -45,6 +45,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-springboot-source-swagger2/pom.xml b/samples/server/petstore/kotlin-springboot-source-swagger2/pom.xml index 121e436cec3e..47fe77d1dc65 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger2/pom.xml +++ b/samples/server/petstore/kotlin-springboot-source-swagger2/pom.xml @@ -139,6 +139,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -151,5 +152,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Category.kt index fbee84d837b1..8e2b19cdf379 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Category( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index b6ac6b461e59..97df19122cab 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.v3.oas.annotations.media.Schema data class ModelApiResponse( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Order.kt index 92c4a5fea678..25a14fcf8421 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.v3.oas.annotations.media.Schema data class Order( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @Schema(example = "null", description = "Order Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Pet.kt index 2e3073226b2c..2ce619534245 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import javax.validation.constraints.DecimalMax @@ -35,17 +37,21 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, @Schema(example = "null", description = "pet status in the store") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Tag.kt index 3a4f18f560d2..5297914c6f01 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.v3.oas.annotations.media.Schema data class Tag( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/User.kt index 7da797736dbd..25a3d62812c8 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.v3.oas.annotations.media.Schema data class User( @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @Schema(example = "null", description = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @Schema(example = "null", description = "User Status") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/build.gradle.kts b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/build.gradle.kts index 36af32631e9a..93c52fa5fc6f 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/build.gradle.kts @@ -47,6 +47,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/pom.xml b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/pom.xml index a812b05160ad..de5c61b2a593 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/pom.xml +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/pom.xml @@ -129,6 +129,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -141,5 +142,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Cat.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Cat.kt index 0a473c42c892..9c4d77f6a75e 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Cat.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Cat.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Color import org.openapitools.model.Pet @@ -43,24 +45,30 @@ data class Cat( @get:JsonProperty("petType", required = true) override val petType: kotlin.String, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("hunts") val hunts: kotlin.Boolean? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("age") val age: kotlin.Int? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") override val id: kotlin.Long? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") override val category: Category? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") override val tags: kotlin.collections.List? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("color") override val color: Color? = null ) : Pet, java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Category.kt index 67d3adb1cd75..33d859b4e8a7 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.annotations.ApiModelProperty data class Category( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") override val id: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") override val name: kotlin.String? = null ) : com.some.pack.CategoryInterface, java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Dog.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Dog.kt index 30027815fb0d..3227118e8756 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Dog.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Dog.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Color import org.openapitools.model.Pet @@ -53,18 +55,22 @@ data class Dog( @get:JsonProperty("petType", required = true) override val petType: kotlin.String, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") override val id: kotlin.Long? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") override val category: Category? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") override val tags: kotlin.collections.List? = null, @field:Valid @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("color") override val color: Color? = null ) : Pet, com.some.pack.Canine, com.some.pack.Fetchable, java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 7cfb2ea3091b..22a9a7ea7618 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -22,12 +24,15 @@ import io.swagger.annotations.ApiModelProperty data class ModelApiResponse( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Order.kt index 59ff0e5d49cf..1dc7672da598 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,21 +29,27 @@ import io.swagger.annotations.ApiModelProperty data class Order( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Pet.kt index 9b03d46e323b..df7bfc8367c9 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Pet.kt @@ -4,9 +4,11 @@ import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonSubTypes import com.fasterxml.jackson.annotation.JsonTypeInfo import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Color import org.openapitools.model.Tag diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Tag.kt index 94ca9b340ad4..636157b0d44f 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -21,9 +23,11 @@ import io.swagger.annotations.ApiModelProperty data class Tag( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/User.kt index 0012d176ce14..7247f2eb5aa3 100644 --- a/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-x-kotlin-implements/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -27,27 +29,35 @@ import io.swagger.annotations.ApiModelProperty data class User( @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, @ApiModelProperty(example = "null", value = "") + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot/build.gradle.kts b/samples/server/petstore/kotlin-springboot/build.gradle.kts index 7dcfd792a49e..9e9df5e59bdd 100644 --- a/samples/server/petstore/kotlin-springboot/build.gradle.kts +++ b/samples/server/petstore/kotlin-springboot/build.gradle.kts @@ -42,6 +42,7 @@ dependencies { implementation("org.springframework.data:spring-data-commons") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("javax.validation:validation-api") + implementation("javax.annotation:javax.annotation-api:1.3.2") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testImplementation("org.springframework.boot:spring-boot-starter-test") { diff --git a/samples/server/petstore/kotlin-springboot/pom.xml b/samples/server/petstore/kotlin-springboot/pom.xml index 37342a0b679b..e41846212fae 100644 --- a/samples/server/petstore/kotlin-springboot/pom.xml +++ b/samples/server/petstore/kotlin-springboot/pom.xml @@ -123,6 +123,7 @@ org.springframework.boot spring-boot-starter-validation + javax.annotation javax.annotation-api @@ -135,5 +136,10 @@ ${kotlin-test-junit5.version} test + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/Application.kt index 2fe6de62479e..e0a7af307d9b 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/Application.kt @@ -6,7 +6,8 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application +class Application { +} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Category.kt index 936b664977b3..9bfdc156868c 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -19,8 +21,10 @@ import javax.validation.Valid */ data class Category( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 8e01881b9571..7618278dd799 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -20,10 +22,13 @@ import javax.validation.Valid */ data class ModelApiResponse( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("code") val code: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("type") val type: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("message") val message: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Order.kt index 3837fc6822be..f8819a1b18e2 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -25,16 +27,22 @@ import javax.validation.Valid */ data class Order( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("petId") val petId: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("quantity") val quantity: kotlin.Int? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Order.Status? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("complete") val complete: kotlin.Boolean? = false ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Pet.kt index 6bf5e554c941..ec6985af729e 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,7 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag import javax.validation.constraints.DecimalMax @@ -31,14 +33,18 @@ data class Pet( @get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("category") val category: Category? = null, @field:Valid + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("tags") val tags: kotlin.collections.List? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("status") val status: Pet.Status? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Tag.kt index 5f31c1eea428..0d5a6c4648ca 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -19,8 +21,10 @@ import javax.validation.Valid */ data class Tag( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("name") val name: kotlin.String? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/User.kt index 07f4aa9cf2c1..517f05a5c709 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/model/User.kt @@ -2,6 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import javax.validation.constraints.DecimalMax import javax.validation.constraints.DecimalMin import javax.validation.constraints.Email @@ -25,20 +27,28 @@ import javax.validation.Valid */ data class User( + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("id") val id: kotlin.Long? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("username") val username: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("firstName") val firstName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("lastName") val lastName: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("email") val email: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("password") val password: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("phone") val phone: kotlin.String? = null, + @field:JsonSetter(nulls = Nulls.FAIL) @get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null ) : java.io.Serializable { diff --git a/samples/server/petstore/springboot-sort-validation/.openapi-generator/FILES b/samples/server/petstore/springboot-sort-validation/.openapi-generator/FILES index 7bb3955083e0..6609ec39c5fe 100644 --- a/samples/server/petstore/springboot-sort-validation/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-sort-validation/.openapi-generator/FILES @@ -3,11 +3,14 @@ pom.xml src/main/java/org/openapitools/OpenApiGeneratorApplication.java src/main/java/org/openapitools/RFC3339DateFormat.java src/main/java/org/openapitools/api/ApiUtil.java +src/main/java/org/openapitools/api/NullableApi.java +src/main/java/org/openapitools/api/NullableApiController.java src/main/java/org/openapitools/api/PetApi.java src/main/java/org/openapitools/configuration/EnumConverterConfiguration.java src/main/java/org/openapitools/configuration/HomeController.java src/main/java/org/openapitools/configuration/ValidPageable.java src/main/java/org/openapitools/configuration/ValidSort.java +src/main/java/org/openapitools/model/NullableModel.java src/main/java/org/openapitools/model/Pet.java src/main/java/org/openapitools/model/PetSort.java src/main/java/org/openapitools/model/PetSortEnum.java diff --git a/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/api/NullableApi.java b/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/api/NullableApi.java new file mode 100644 index 000000000000..ea75d1c9ddb1 --- /dev/null +++ b/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/api/NullableApi.java @@ -0,0 +1,79 @@ +/* + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.23.0-SNAPSHOT). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package org.openapitools.api; + +import org.openapitools.model.NullableModel; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import jakarta.annotation.Generated; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.23.0-SNAPSHOT") +@Validated +@RequestMapping("${openapi.openAPIPetstoreSortValidationTest.base-path:/v2}") +public interface NullableApi { + + String PATH_CHECK_ALL_PRESENT = "/nullable/check-all-present"; + /** + * POST /nullable/check-all-present : POST with all 4 fields present — impl asserts each field has the expected value + * + * @param nullableModel (required) + * @return OK — assertions in impl passed (status code 200) + * or Bad request (status code 400) + */ + @RequestMapping( + method = RequestMethod.POST, + value = NullableApi.PATH_CHECK_ALL_PRESENT, + consumes = { "application/json" } + ) + ResponseEntity checkAllPresent( + @Valid @RequestBody NullableModel nullableModel + ); + + + String PATH_CHECK_OPTIONAL_NULLABLE_NULL = "/nullable/check-optional-nullable-null"; + /** + * POST /nullable/check-optional-nullable-null : POST with optionalNullable set to null — impl asserts JsonNullable is present-with-null + * + * @param nullableModel (required) + * @return OK — assertions in impl passed (status code 200) + * or Bad request (status code 400) + */ + @RequestMapping( + method = RequestMethod.POST, + value = NullableApi.PATH_CHECK_OPTIONAL_NULLABLE_NULL, + consumes = { "application/json" } + ) + ResponseEntity checkOptionalNullableNull( + @Valid @RequestBody NullableModel nullableModel + ); + + + String PATH_CHECK_REQUIRED_ONLY = "/nullable/check-required-only"; + /** + * POST /nullable/check-required-only : POST with only required fields — impl asserts optional fields are absent/undefined + * + * @param nullableModel (required) + * @return OK — assertions in impl passed (status code 200) + * or Bad request (status code 400) + */ + @RequestMapping( + method = RequestMethod.POST, + value = NullableApi.PATH_CHECK_REQUIRED_ONLY, + consumes = { "application/json" } + ) + ResponseEntity checkRequiredOnly( + @Valid @RequestBody NullableModel nullableModel + ); + +} diff --git a/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/api/NullableApiController.java b/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/api/NullableApiController.java new file mode 100644 index 000000000000..20706114434b --- /dev/null +++ b/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/api/NullableApiController.java @@ -0,0 +1,45 @@ +package org.openapitools.api; + +import org.openapitools.model.NullableModel; + + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.CookieValue; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.context.request.NativeWebRequest; + +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; + +import java.util.List; +import java.util.Map; +import java.util.Optional; +import jakarta.annotation.Generated; + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.23.0-SNAPSHOT") +@Controller +public class NullableApiController implements NullableApi { + + private final NativeWebRequest request; + + @Autowired + public NullableApiController(NativeWebRequest request) { + this.request = request; + } + + @Override + public Optional getRequest() { + return Optional.ofNullable(request); + } + +} diff --git a/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/model/NullableModel.java b/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/model/NullableModel.java new file mode 100644 index 000000000000..3c93d0c3e206 --- /dev/null +++ b/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/model/NullableModel.java @@ -0,0 +1,180 @@ +package org.openapitools.model; + +import java.net.URI; +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Arrays; +import org.openapitools.jackson.nullable.JsonNullable; +import org.springframework.lang.Nullable; +import java.util.NoSuchElementException; +import org.openapitools.jackson.nullable.JsonNullable; +import java.io.Serializable; +import java.time.OffsetDateTime; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + + +import java.util.*; +import jakarta.annotation.Generated; + +/** + * NullableModel + */ + +@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.23.0-SNAPSHOT") +public class NullableModel implements Serializable { + + private static final long serialVersionUID = 1L; + + private String requiredNonNullable; + + private JsonNullable requiredNullable = JsonNullable.undefined(); + + private @Nullable String optionalNonNullable; + + private JsonNullable optionalNullable = JsonNullable.undefined(); + + public NullableModel() { + super(); + } + + /** + * Constructor with only required parameters + */ + public NullableModel(String requiredNonNullable, String requiredNullable) { + this.requiredNonNullable = requiredNonNullable; + this.requiredNullable = JsonNullable.of(requiredNullable); + } + + public NullableModel requiredNonNullable(String requiredNonNullable) { + this.requiredNonNullable = requiredNonNullable; + return this; + } + + /** + * Get requiredNonNullable + * @return requiredNonNullable + */ + @NotNull + @JsonProperty("requiredNonNullable") + public String getRequiredNonNullable() { + return requiredNonNullable; + } + + @JsonProperty("requiredNonNullable") + public void setRequiredNonNullable(String requiredNonNullable) { + this.requiredNonNullable = requiredNonNullable; + } + + public NullableModel requiredNullable(String requiredNullable) { + this.requiredNullable = JsonNullable.of(requiredNullable); + return this; + } + + /** + * Get requiredNullable + * @return requiredNullable + */ + @NotNull + @JsonProperty("requiredNullable") + public JsonNullable getRequiredNullable() { + return requiredNullable; + } + + @JsonProperty("requiredNullable") + public void setRequiredNullable(JsonNullable requiredNullable) { + this.requiredNullable = requiredNullable; + } + + public NullableModel optionalNonNullable(@Nullable String optionalNonNullable) { + this.optionalNonNullable = optionalNonNullable; + return this; + } + + /** + * Get optionalNonNullable + * @return optionalNonNullable + */ + + @JsonProperty("optionalNonNullable") + public @Nullable String getOptionalNonNullable() { + return optionalNonNullable; + } + + @JsonProperty("optionalNonNullable") + public void setOptionalNonNullable(@Nullable String optionalNonNullable) { + this.optionalNonNullable = optionalNonNullable; + } + + public NullableModel optionalNullable(String optionalNullable) { + this.optionalNullable = JsonNullable.of(optionalNullable); + return this; + } + + /** + * Get optionalNullable + * @return optionalNullable + */ + + @JsonProperty("optionalNullable") + public JsonNullable getOptionalNullable() { + return optionalNullable; + } + + public void setOptionalNullable(JsonNullable optionalNullable) { + this.optionalNullable = optionalNullable; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NullableModel nullableModel = (NullableModel) o; + return Objects.equals(this.requiredNonNullable, nullableModel.requiredNonNullable) && + Objects.equals(this.requiredNullable, nullableModel.requiredNullable) && + Objects.equals(this.optionalNonNullable, nullableModel.optionalNonNullable) && + equalsNullable(this.optionalNullable, nullableModel.optionalNullable); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(requiredNonNullable, requiredNullable, optionalNonNullable, hashCodeNullable(optionalNullable)); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NullableModel {\n"); + sb.append(" requiredNonNullable: ").append(toIndentedString(requiredNonNullable)).append("\n"); + sb.append(" requiredNullable: ").append(toIndentedString(requiredNullable)).append("\n"); + sb.append(" optionalNonNullable: ").append(toIndentedString(optionalNonNullable)).append("\n"); + sb.append(" optionalNullable: ").append(toIndentedString(optionalNullable)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(@Nullable Object o) { + return o == null ? "null" : o.toString().replace("\n", "\n "); + } +} + diff --git a/samples/server/petstore/springboot-sort-validation/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-sort-validation/src/main/resources/openapi.yaml index 295696bfc7fe..5763ce44186b 100644 --- a/samples/server/petstore/springboot-sort-validation/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-sort-validation/src/main/resources/openapi.yaml @@ -757,6 +757,74 @@ paths: - application/json x-tags: - tag: pet + /nullable/check-required-only: + post: + operationId: checkRequiredOnly + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/NullableModel" + required: true + responses: + "200": + description: OK — assertions in impl passed + "400": + description: Bad request + summary: POST with only required fields — impl asserts optional fields are absent/undefined + tags: + - nullable + x-content-type: application/json + x-accepts: + - application/json + x-tags: + - tag: nullable + /nullable/check-optional-nullable-null: + post: + operationId: checkOptionalNullableNull + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/NullableModel" + required: true + responses: + "200": + description: OK — assertions in impl passed + "400": + description: Bad request + summary: POST with optionalNullable set to null — impl asserts JsonNullable + is present-with-null + tags: + - nullable + x-content-type: application/json + x-accepts: + - application/json + x-tags: + - tag: nullable + /nullable/check-all-present: + post: + operationId: checkAllPresent + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/NullableModel" + required: true + responses: + "200": + description: OK — assertions in impl passed + "400": + description: Bad request + summary: POST with all 4 fields present — impl asserts each field has the expected + value + tags: + - nullable + x-content-type: application/json + x-accepts: + - application/json + x-tags: + - tag: nullable components: parameters: PetSortParam: @@ -783,6 +851,29 @@ components: type: array style: form schemas: + NullableModel: + example: + requiredNonNullable: requiredNonNullable + requiredNullable: requiredNullable + optionalNonNullable: optionalNonNullable + optionalNullable: optionalNullable + properties: + requiredNonNullable: + nullable: false + type: string + requiredNullable: + nullable: true + type: string + optionalNonNullable: + nullable: false + type: string + optionalNullable: + nullable: true + type: string + required: + - requiredNonNullable + - requiredNullable + type: object PetSort: enum: - "id,asc" From eac10fd952c092a027d1cf5e33aaa6c34bfb3952 Mon Sep 17 00:00:00 2001 From: Jachym Metlicka Date: Sun, 17 May 2026 16:11:52 +0200 Subject: [PATCH 3/9] add more tests for prefix/suffix --- .../springBootApplication.mustache | 7 +- .../spring/KotlinSpringServerCodegenTest.java | 67 +++++++++++++++++++ .../kotlin/required-nullable-ref-type.yaml | 38 +++++++++++ 3 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 modules/openapi-generator/src/test/resources/3_0/kotlin/required-nullable-ref-type.yaml diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/springBootApplication.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/springBootApplication.mustache index 7f03ca475c58..230110c9b0aa 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/springBootApplication.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/springBootApplication.mustache @@ -11,12 +11,15 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["{{basePackage}}", "{{apiPackage}}", "{{modelPackage}}"]) -class Application { {{#openApiNullable}} +class Application { @Bean(name = ["{{basePackage}}.Application.jsonNullableModule"]) fun jsonNullableModule(): Module = JsonNullableModule() -{{/openApiNullable}} } +{{/openApiNullable}} +{{^openApiNullable}} +class Application +{{/openApiNullable}} fun main(args: Array) { runApplication(*args) diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java index ea3d049750a1..075efe69c4b8 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java @@ -6262,4 +6262,71 @@ public void requiredNullable_scenario4_optionalNullable_withOpenApiNullable_jack // Must NOT be a plain nullable type assertFileNotContains(modelFile, "val optionalNullable: kotlin.String? = null"); } + + /** + * Scenario 4 with modelNameSuffix: the generated file is renamed (e.g. TestModelDto.kt) + * but JsonNullable wrapping must still be applied to the optional+nullable property. + */ + @Test(description = "Scenario 4 – openApiNullable=true + modelNameSuffix: JsonNullable present in renamed model file") + public void requiredNullable_scenario4_withModelNameSuffix() throws IOException { + Map props = new HashMap<>(); + props.put(CodegenConstants.OPENAPI_NULLABLE, "true"); + Map files = generateFromContract( + "src/test/resources/3_0/kotlin/required-nullable-4-states.yaml", + props, + new HashMap<>(), + configurator -> configurator.setModelNameSuffix("Dto")); + + // File must be renamed + Assert.assertNotNull(files.get("TestModelDto.kt"), "Expected TestModelDto.kt to be generated"); + Assert.assertNull(files.get("TestModel.kt"), "TestModel.kt must not exist when suffix=Dto"); + + Path modelFile = files.get("TestModelDto.kt").toPath(); + assertFileContains(modelFile, "JsonNullable"); + assertFileContains(modelFile, "= JsonNullable.undefined()"); + assertFileContains(modelFile, "import org.openapitools.jackson.nullable.JsonNullable"); + } + + /** + * Scenario 4 with modelNamePrefix: the generated file is renamed (e.g. ApiTestModel.kt) + * but JsonNullable wrapping must still be applied. + */ + @Test(description = "Scenario 4 – openApiNullable=true + modelNamePrefix: JsonNullable present in renamed model file") + public void requiredNullable_scenario4_withModelNamePrefix() throws IOException { + Map props = new HashMap<>(); + props.put(CodegenConstants.OPENAPI_NULLABLE, "true"); + Map files = generateFromContract( + "src/test/resources/3_0/kotlin/required-nullable-4-states.yaml", + props, + new HashMap<>(), + configurator -> configurator.setModelNamePrefix("Api")); + + Assert.assertNotNull(files.get("ApiTestModel.kt"), "Expected ApiTestModel.kt to be generated"); + Assert.assertNull(files.get("TestModel.kt"), "TestModel.kt must not exist when prefix=Api"); + + Path modelFile = files.get("ApiTestModel.kt").toPath(); + assertFileContains(modelFile, "JsonNullable"); + assertFileContains(modelFile, "= JsonNullable.undefined()"); + assertFileContains(modelFile, "import org.openapitools.jackson.nullable.JsonNullable"); + } + + /** + * Scenario 4 with schemaMapping: when the type of an optional+nullable property is a $ref + * that is schema-mapped to an external class, JsonNullable must wrap the mapped type. + */ + @Test(description = "Scenario 4 – openApiNullable=true + schemaMapping: JsonNullable wraps the mapped external type") + public void requiredNullable_scenario4_withSchemaMapping() throws IOException { + Map files = generateFromContract( + "src/test/resources/3_0/kotlin/required-nullable-ref-type.yaml", + Map.of(CodegenConstants.OPENAPI_NULLABLE, "true"), + new HashMap<>(), + configurator -> configurator.setSchemaMappings( + Map.of("RefType", "com.example.ExternalType"))); + + Path modelFile = files.get("TestModel.kt").toPath(); + // The optional nullable ref property must be wrapped with the mapped external type + assertFileContains(modelFile, "JsonNullable"); + assertFileContains(modelFile, "= JsonNullable.undefined()"); + assertFileContains(modelFile, "import org.openapitools.jackson.nullable.JsonNullable"); + } } diff --git a/modules/openapi-generator/src/test/resources/3_0/kotlin/required-nullable-ref-type.yaml b/modules/openapi-generator/src/test/resources/3_0/kotlin/required-nullable-ref-type.yaml new file mode 100644 index 000000000000..0dba994fee18 --- /dev/null +++ b/modules/openapi-generator/src/test/resources/3_0/kotlin/required-nullable-ref-type.yaml @@ -0,0 +1,38 @@ +openapi: 3.0.0 +info: + title: Required and Nullable with Ref Type Test + version: 1.0.0 +paths: + /test: + post: + operationId: testPost + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TestModel' + responses: + '200': + description: OK +components: + schemas: + RefType: + type: object + properties: + value: + type: string + TestModel: + type: object + required: + - requiredNonNullable + properties: + # required non-nullable (baseline) + requiredNonNullable: + type: string + nullable: false + # Scenario 4 variant: optional, nullable, type is a $ref — should be JsonNullable + # (or JsonNullable when RefType is schema-mapped) + optionalNullableRef: + nullable: true + allOf: + - $ref: '#/components/schemas/RefType' From 2fb7b247504ccf606464c9d8da80f732cfe67dc3 Mon Sep 17 00:00:00 2001 From: Jachym Metlicka Date: Sun, 17 May 2026 16:15:04 +0200 Subject: [PATCH 4/9] improve springBootApplication.mustache structure --- .../libraries/spring-boot/springBootApplication.mustache | 9 ++------- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- .../src/main/kotlin/org/openapitools/Application.kt | 3 +-- 19 files changed, 20 insertions(+), 43 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/springBootApplication.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/springBootApplication.mustache index 230110c9b0aa..da5763a3383e 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/springBootApplication.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/libraries/spring-boot/springBootApplication.mustache @@ -11,15 +11,10 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["{{basePackage}}", "{{apiPackage}}", "{{modelPackage}}"]) -{{#openApiNullable}} -class Application { +class Application{{#openApiNullable}} { @Bean(name = ["{{basePackage}}.Application.jsonNullableModule"]) fun jsonNullableModule(): Module = JsonNullableModule() -} -{{/openApiNullable}} -{{^openApiNullable}} -class Application -{{/openApiNullable}} +}{{/openApiNullable}} fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-spring-default/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-3-no-response-entity/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-3/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-additionalproperties/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-bigdecimal-default/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-bigdecimal-default/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-bigdecimal-default/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-bigdecimal-default/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-delegate-nodefaults/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-delegate/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-include-http-request-context-delegate/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-modelMutable/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-multipart-request-model/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-multipart-request-model/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-multipart-request-model/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-multipart-request-model/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity-delegate/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-no-response-entity/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-reactive-without-flow/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-reactive/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger1/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot-source-swagger2/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) diff --git a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/Application.kt b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/Application.kt index e0a7af307d9b..2fe6de62479e 100644 --- a/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/Application.kt +++ b/samples/server/petstore/kotlin-springboot/src/main/kotlin/org/openapitools/Application.kt @@ -6,8 +6,7 @@ import org.springframework.context.annotation.ComponentScan @SpringBootApplication @ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"]) -class Application { -} +class Application fun main(args: Array) { runApplication(*args) From e737900d34a8f3bf2f1480b54f239f04e345e866 Mon Sep 17 00:00:00 2001 From: Jachym Metlicka Date: Sun, 17 May 2026 16:49:59 +0200 Subject: [PATCH 5/9] regenerate samples --- .../petstore/springboot-sort-validation/.openapi-generator/FILES | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/server/petstore/springboot-sort-validation/.openapi-generator/FILES b/samples/server/petstore/springboot-sort-validation/.openapi-generator/FILES index 6609ec39c5fe..da2d4c6d3b44 100644 --- a/samples/server/petstore/springboot-sort-validation/.openapi-generator/FILES +++ b/samples/server/petstore/springboot-sort-validation/.openapi-generator/FILES @@ -4,7 +4,6 @@ src/main/java/org/openapitools/OpenApiGeneratorApplication.java src/main/java/org/openapitools/RFC3339DateFormat.java src/main/java/org/openapitools/api/ApiUtil.java src/main/java/org/openapitools/api/NullableApi.java -src/main/java/org/openapitools/api/NullableApiController.java src/main/java/org/openapitools/api/PetApi.java src/main/java/org/openapitools/configuration/EnumConverterConfiguration.java src/main/java/org/openapitools/configuration/HomeController.java From fc52cd60704f0dd0990d201adfcb78b805e60211 Mon Sep 17 00:00:00 2001 From: Jachym Metlicka Date: Sun, 17 May 2026 17:01:48 +0200 Subject: [PATCH 6/9] fix test --- .../org/openapitools/codegen/java/JavaClientCodegenTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java index 42a46f9e0049..e593b0cccf5c 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java @@ -733,6 +733,7 @@ void supportsJackson3WithOpenApiNullableForSpringBoot4Libraries(String library) .addAdditionalProperty(USE_JACKSON_3, true) .addAdditionalProperty(USE_SPRING_BOOT4, true) .addAdditionalProperty(JavaClientCodegen.OPENAPI_NULLABLE, true) + .setInputSpec("src/test/resources/3_0/java/autoset_constant.yaml") .setOutputDir(outputDir); List files = new DefaultGenerator().opts(configurator.toClientOptInput()).generate(); From d7badae0bbac7fe7ee75eabb6e82f27a1a759837 Mon Sep 17 00:00:00 2001 From: Jachym Metlicka Date: Sun, 17 May 2026 21:00:35 +0200 Subject: [PATCH 7/9] update documentation --- docs/generators/kotlin-spring.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/generators/kotlin-spring.md b/docs/generators/kotlin-spring.md index df2ec9ff370a..9838ac83a85b 100644 --- a/docs/generators/kotlin-spring.md +++ b/docs/generators/kotlin-spring.md @@ -44,8 +44,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl |library|library template (sub-template)|
**spring-boot**
Spring-boot Server application.
**spring-cloud**
Spring-Cloud-Feign client with Spring-Boot auto-configured settings.
**spring-declarative-http-interface**
Spring Declarative Interface client
|spring-boot| |modelMutable|Create mutable models| |false| |modelPackage|model package for generated code| |org.openapitools.model| +|openApiNullable|Enable OpenAPI Jackson Nullable library (jackson-databind-nullable) for optional + nullable properties (required: false, nullable: true). When enabled, such properties use JsonNullable<T> = JsonNullable.undefined() so callers can distinguish between a missing key and an explicitly provided null. Requires jackson-databind-nullable >= 0.2.10 when used with useJackson3.| |false| |packageName|Generated artifact package name.| |org.openapitools| -|openApiNullable|Enable OpenAPI Jackson Nullable library (org.openapitools.jackson.nullable.JsonNullable) to represent `required: false, nullable: true` schema properties as a 3-state type (present/null/absent). Adds `jackson-databind-nullable` dependency to generated build files. Compatible with both Jackson 2 and Jackson 3 (requires jackson-databind-nullable ≥ 0.2.10).| |false| |parcelizeModels|toggle "@Parcelize" for generated models| |null| |reactive|use coroutines for reactive behavior| |false| |requestMappingMode|Where to generate the class level @RequestMapping annotation.|
**api_interface**
Generate the @RequestMapping annotation on the generated Api Interface.
**controller**
Generate the @RequestMapping annotation on the generated Api Controller Implementation.
**none**
Do not add a class level @RequestMapping annotation.
|controller| @@ -65,7 +65,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |useDeductionForOneOfInterfaces|Annotate discriminator-free oneOf interfaces with Jackson's @JsonTypeInfo(use = Id.DEDUCTION) and @JsonSubTypes so the concrete subtype is resolved from the JSON field set rather than a type-tag property. Has no effect when a discriminator is present (name-based resolution is used instead). Requires subtypes to have structurally distinct sets of properties.| |false| |useFeignClientUrl|Whether to generate Feign client with url parameter.| |true| |useFlowForArrayReturnType|Whether to use Flow for array/collection return types when reactive is enabled. If false, will use List instead.| |true| -|useJackson3|Use Jackson 3 dependencies (tools.jackson package). Only available with `useSpringBoot4`. Defaults to true when `useSpringBoot4` is enabled. Compatible with `openApiNullable` (requires jackson-databind-nullable ≥ 0.2.10).| |false| +|useJackson3|Use Jackson 3 dependencies (tools.jackson package). Only available with `useSpringBoot4`. Defaults to true when `useSpringBoot4` is enabled.| |false| |useResponseEntity|Whether (when false) to return actual type (e.g. List<Fruit>) and handle non-happy path responses via exceptions flow or (when true) return entire ResponseEntity (e.g. ResponseEntity<List<Fruit>>). If disabled, method are annotated using a @ResponseStatus annotation, which has the status of the first response declared in the Api definition| |true| |useSealedResponseInterfaces|Generate sealed interfaces for endpoint responses that all possible response types implement. Allows controllers to return any valid response type in a type-safe manner (e.g., sealed interface CreateUserResponse implemented by User, ConflictResponse, ErrorResponse)| |false| |useSpringBoot3|Generate code and provide dependencies for use with Spring Boot ≥ 3 (use jakarta instead of javax in imports). Enabling this option will also enable `useJakartaEe`.| |false| From 9f9463b96c000144eee7b2036ec5989c5ad74d72 Mon Sep 17 00:00:00 2001 From: Jachym Metlicka Date: Sun, 17 May 2026 23:32:29 +0200 Subject: [PATCH 8/9] fix jackson-annotations import package. regenerate samples --- .../languages/KotlinSpringServerCodegen.java | 4 +- .../spring/KotlinSpringServerCodegenTest.java | 11 +- .../kotlin/org/openapitools/model/Category.kt | 4 +- .../openapitools/model/ModelApiResponse.kt | 4 +- .../kotlin/org/openapitools/model/Order.kt | 4 +- .../main/kotlin/org/openapitools/model/Pet.kt | 4 +- .../main/kotlin/org/openapitools/model/Tag.kt | 4 +- .../kotlin/org/openapitools/model/User.kt | 4 +- .../api/NullableApiController.java | 117 +++++++++++++----- 9 files changed, 108 insertions(+), 48 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java index b3df33a2b61c..dcab9e737072 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java @@ -553,8 +553,8 @@ public void processOpts() { if (isUseJackson3()) { // Override databind imports for Jackson 3 importMapping.put("JsonDeserialize", "tools.jackson.databind.annotation.JsonDeserialize"); - importMapping.put("JsonSetter", "tools.jackson.annotation.JsonSetter"); - importMapping.put("Nulls", "tools.jackson.annotation.Nulls"); + importMapping.put("JsonSetter", "com.fasterxml.jackson.annotation.JsonSetter"); + importMapping.put("Nulls", "com.fasterxml.jackson.annotation.Nulls"); // jackson-databind-nullable >= 0.2.10 supports both Jackson 2 and 3; // the JsonNullable class lives in the same package regardless of Jackson version. importMapping.put("JsonNullable", "org.openapitools.jackson.nullable.JsonNullable"); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java index 075efe69c4b8..87c5938d74bf 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java @@ -6217,9 +6217,10 @@ public void requiredNullable_scenario4_optionalNullable_withOpenApiNullable() th /** * Scenario 3 with Jackson 3 (Spring Boot 4): optional + non-nullable. - * @JsonSetter / Nulls imports should come from tools.jackson.annotation. + * @JsonSetter / Nulls imports should come from com.fasterxml.jackson.annotation + * (Jackson 3.x intentionally kept jackson-annotations at 2.x, same package). */ - @Test(description = "Scenario 3 with Jackson 3: tools.jackson.annotation.JsonSetter + Nulls imports") + @Test(description = "Scenario 3 with Jackson 3: com.fasterxml.jackson.annotation.JsonSetter + Nulls imports") public void requiredNullable_scenario3_optionalNonNullable_withJackson3() throws IOException { Map props = new HashMap<>(); props.put(KotlinSpringServerCodegen.USE_SPRING_BOOT4, "true"); @@ -6230,10 +6231,10 @@ public void requiredNullable_scenario3_optionalNonNullable_withJackson3() throws Path modelFile = files.get("TestModel.kt").toPath(); // Annotation must still be rendered assertFileContains(modelFile, "@field:JsonSetter(nulls = Nulls.FAIL)"); - // Imports must come from tools.jackson (Jackson 3 package) + // Imports must come from com.fasterxml.jackson.annotation (Jackson 3.x keeps annotations at 2.x) assertFileContains(modelFile, - "import tools.jackson.annotation.JsonSetter", - "import tools.jackson.annotation.Nulls"); + "import com.fasterxml.jackson.annotation.JsonSetter", + "import com.fasterxml.jackson.annotation.Nulls"); // Must be nullable type with null default assertFileContains(modelFile, "val optionalNonNullable: kotlin.String? = null"); } diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Category.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Category.kt index 606e55e5466a..a21009655d77 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Category.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Category.kt @@ -2,8 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty -import tools.jackson.annotation.JsonSetter -import tools.jackson.annotation.Nulls +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt index 186af830f366..b0ca34c2fa9e 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/ModelApiResponse.kt @@ -2,8 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty -import tools.jackson.annotation.JsonSetter -import tools.jackson.annotation.Nulls +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Order.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Order.kt index 8dc477d7fea9..7dcae28c0485 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Order.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Order.kt @@ -3,9 +3,9 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue -import tools.jackson.annotation.JsonSetter -import tools.jackson.annotation.Nulls +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Pet.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Pet.kt index c6a8c67b131e..fb6a4ba5a866 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Pet.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Pet.kt @@ -3,11 +3,11 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.annotation.JsonSetter import com.fasterxml.jackson.annotation.JsonValue +import com.fasterxml.jackson.annotation.Nulls import org.openapitools.model.Category import org.openapitools.model.Tag -import tools.jackson.annotation.JsonSetter -import tools.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Tag.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Tag.kt index cd79877cd5b9..a5a0baad98c8 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Tag.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/Tag.kt @@ -2,8 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty -import tools.jackson.annotation.JsonSetter -import tools.jackson.annotation.Nulls +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email diff --git a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/User.kt b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/User.kt index 856b11893340..409a68510ec0 100644 --- a/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/User.kt +++ b/samples/server/petstore/kotlin-springboot-4/src/main/kotlin/org/openapitools/model/User.kt @@ -2,8 +2,8 @@ package org.openapitools.model import java.util.Objects import com.fasterxml.jackson.annotation.JsonProperty -import tools.jackson.annotation.JsonSetter -import tools.jackson.annotation.Nulls +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls import jakarta.validation.constraints.DecimalMax import jakarta.validation.constraints.DecimalMin import jakarta.validation.constraints.Email diff --git a/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/api/NullableApiController.java b/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/api/NullableApiController.java index 20706114434b..a0f5a563fad7 100644 --- a/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/api/NullableApiController.java +++ b/samples/server/petstore/springboot-sort-validation/src/main/java/org/openapitools/api/NullableApiController.java @@ -2,44 +2,103 @@ import org.openapitools.model.NullableModel; - -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.context.request.NativeWebRequest; - -import jakarta.validation.constraints.*; -import jakarta.validation.Valid; +import org.springframework.web.bind.annotation.RestController; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import jakarta.annotation.Generated; +import jakarta.validation.Valid; -@Generated(value = "org.openapitools.codegen.languages.SpringCodegen", comments = "Generator version: 7.23.0-SNAPSHOT") -@Controller +/** + * Sample implementation of {@link NullableApi} demonstrating that the generated + * nullable annotations work correctly at runtime. + * + * Each method receives a deserialized {@link NullableModel} and asserts the expected + * state of its fields. When Jackson correctly applies {@code @JsonSetter(nulls = Nulls.FAIL)} + * and {@code JsonNullable}, the assertions pass and HTTP 200 is returned. If the + * deserialized state is wrong, the assertion throws {@link IllegalStateException} and + * the request fails with HTTP 500, causing any calling test to fail with a clear message. + */ +@RestController public class NullableApiController implements NullableApi { - private final NativeWebRequest request; - - @Autowired - public NullableApiController(NativeWebRequest request) { - this.request = request; + /** + * POST with only required fields — asserts optional fields are absent/undefined. + * + * The JSON body contains only the two required fields; both optional fields are absent. + * Expected state: + *
    + *
  • {@code optionalNonNullable} → {@code null} (absent key → default null)
  • + *
  • {@code optionalNullable} → {@code JsonNullable.undefined()} (absent key → undefined)
  • + *
+ */ + @Override + public ResponseEntity checkRequiredOnly(@Valid NullableModel nullableModel) { + if (nullableModel.getOptionalNonNullable() != null) { + throw new IllegalStateException( + "optionalNonNullable: expected null (absent from JSON), got " + + nullableModel.getOptionalNonNullable()); + } + if (nullableModel.getOptionalNullable().isPresent()) { + throw new IllegalStateException( + "optionalNullable: expected JsonNullable.undefined() (absent from JSON), got " + + nullableModel.getOptionalNullable()); + } + return new ResponseEntity<>(HttpStatus.OK); } + /** + * POST with optionalNullable set to null — asserts JsonNullable is present-with-null. + * + * The JSON body contains the required fields plus {@code "optionalNullable": null}. + * Expected state: + *
    + *
  • {@code optionalNullable} → {@code JsonNullable.of(null)} + * (key present with null value → isPresent = true, get() = null)
  • + *
+ */ @Override - public Optional getRequest() { - return Optional.ofNullable(request); + public ResponseEntity checkOptionalNullableNull(@Valid NullableModel nullableModel) { + if (!nullableModel.getOptionalNullable().isPresent()) { + throw new IllegalStateException( + "optionalNullable: expected JsonNullable present (explicit null in JSON), got " + + nullableModel.getOptionalNullable()); + } + if (nullableModel.getOptionalNullable().get() != null) { + throw new IllegalStateException( + "optionalNullable: expected null inner value, got " + + nullableModel.getOptionalNullable().get()); + } + return new ResponseEntity<>(HttpStatus.OK); } + /** + * POST with all 4 fields present — asserts each field has the expected value. + * + * The JSON body contains all four fields with non-null string values. + * Expected state: + *
    + *
  • {@code optionalNonNullable} → {@code "opt-non-null"}
  • + *
  • {@code optionalNullable} → {@code JsonNullable.of("opt-nullable")} (isPresent, non-null value)
  • + *
+ */ + @Override + public ResponseEntity checkAllPresent(@Valid NullableModel nullableModel) { + if (!"opt-non-null".equals(nullableModel.getOptionalNonNullable())) { + throw new IllegalStateException( + "optionalNonNullable: expected 'opt-non-null', got " + + nullableModel.getOptionalNonNullable()); + } + if (!nullableModel.getOptionalNullable().isPresent()) { + throw new IllegalStateException( + "optionalNullable: expected JsonNullable present, got " + + nullableModel.getOptionalNullable()); + } + if (!"opt-nullable".equals(nullableModel.getOptionalNullable().get())) { + throw new IllegalStateException( + "optionalNullable: expected 'opt-nullable', got " + + nullableModel.getOptionalNullable().get()); + } + return new ResponseEntity<>(HttpStatus.OK); + } } + From 1cbd6196e146cc64d1d5ee83f839e4c19c15fdcf Mon Sep 17 00:00:00 2001 From: Jachym Metlicka Date: Mon, 18 May 2026 00:23:10 +0200 Subject: [PATCH 9/9] refactor import mappings for Jackson 3.x support and improve clarity --- .../languages/KotlinSpringServerCodegen.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java index dcab9e737072..7bc6bb393a8d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java @@ -550,19 +550,14 @@ public void processOpts() { // used later in recursive import in postProcessingModels importMapping.put("com.fasterxml.jackson.annotation.JsonProperty", "com.fasterxml.jackson.annotation.JsonCreator"); - if (isUseJackson3()) { - // Override databind imports for Jackson 3 - importMapping.put("JsonDeserialize", "tools.jackson.databind.annotation.JsonDeserialize"); - importMapping.put("JsonSetter", "com.fasterxml.jackson.annotation.JsonSetter"); - importMapping.put("Nulls", "com.fasterxml.jackson.annotation.Nulls"); - // jackson-databind-nullable >= 0.2.10 supports both Jackson 2 and 3; - // the JsonNullable class lives in the same package regardless of Jackson version. - importMapping.put("JsonNullable", "org.openapitools.jackson.nullable.JsonNullable"); - } else { - importMapping.put("JsonSetter", "com.fasterxml.jackson.annotation.JsonSetter"); - importMapping.put("Nulls", "com.fasterxml.jackson.annotation.Nulls"); - importMapping.put("JsonNullable", "org.openapitools.jackson.nullable.JsonNullable"); - } + // Jackson 3.x intentionally kept jackson-annotations at 2.x (com.fasterxml.jackson.annotation). + // Only jackson-databind moved to tools.jackson.databind in Jackson 3.x. + importMapping.put("JsonSetter", "com.fasterxml.jackson.annotation.JsonSetter"); + importMapping.put("Nulls", "com.fasterxml.jackson.annotation.Nulls"); + // jackson-databind-nullable >= 0.2.10 supports both Jackson 2 and 3. + importMapping.put("JsonNullable", "org.openapitools.jackson.nullable.JsonNullable"); + // JsonDeserialize lives in jackson-databind which moved packages in Jackson 3.x. + importMapping.put("JsonDeserialize", (isUseJackson3() ? JACKSON3_PACKAGE : JACKSON2_PACKAGE) + ".databind.annotation.JsonDeserialize"); // Spring-specific import mappings for x-spring-paginated support importMapping.put("ParameterObject", "org.springdoc.api.annotations.ParameterObject");