From 287b7eabb715868bff7e72c05d0b0523ffbf4705 Mon Sep 17 00:00:00 2001 From: cbornet Date: Tue, 5 Jan 2021 15:58:39 +0100 Subject: [PATCH 1/2] Fix required model property deserialization --- .../main/resources/kotlin-spring/dataClassOptVar.mustache | 5 ++--- .../main/resources/kotlin-spring/dataClassReqVar.mustache | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) 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 b44f43adf85e..ec3c8fd6983c 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/dataClassOptVar.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/dataClassOptVar.mustache @@ -1,5 +1,4 @@ -{{#useBeanValidation}}{{#required}}{{^isReadOnly}} - @get:NotNull{{/isReadOnly}}{{/required}}{{>beanValidation}}{{>beanValidationModel}}{{/useBeanValidation}}{{#swaggerAnnotations}} - @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swaggerAnnotations}}{{#deprecated}} +{{#useBeanValidation}}{{>beanValidation}}{{>beanValidationModel}}{{/useBeanValidation}}{{#swaggerAnnotations}} + @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swaggerAnnotations}}{{#deprecated}} @Deprecated(message = ""){{/deprecated}} @field:JsonProperty("{{{baseName}}}"){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{nameInCamelCase}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{#defaultvalue}}{{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/kotlin-spring/dataClassReqVar.mustache b/modules/openapi-generator/src/main/resources/kotlin-spring/dataClassReqVar.mustache index b67cb59905bb..963baa8f9af9 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-spring/dataClassReqVar.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-spring/dataClassReqVar.mustache @@ -1,4 +1,3 @@ -{{#useBeanValidation}}{{#required}}{{^isReadOnly}} - @get:NotNull {{/isReadOnly}}{{/required}}{{>beanValidation}}{{>beanValidationModel}}{{/useBeanValidation}}{{#swaggerAnnotations}} - @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swaggerAnnotations}} - @field:JsonProperty("{{{baseName}}}"){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{nameInCamelCase}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isReadOnly}}? = {{#defaultvalue}}{{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}{{/isReadOnly}} \ No newline at end of file +{{#useBeanValidation}}{{>beanValidation}}{{>beanValidationModel}}{{/useBeanValidation}}{{#swaggerAnnotations}} + @ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}required = true, {{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swaggerAnnotations}} + @field:JsonProperty("{{{baseName}}}", required = true){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{nameInCamelCase}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isReadOnly}}? = {{#defaultvalue}}{{defaultvalue}}{{/defaultvalue}}{{^defaultvalue}}null{{/defaultvalue}}{{/isReadOnly}} \ No newline at end of file From 572de0a54515d90f27c3167d4de63e7228f1f553 Mon Sep 17 00:00:00 2001 From: cbornet Date: Tue, 5 Jan 2021 16:10:35 +0100 Subject: [PATCH 2/2] Update samples --- .../src/main/kotlin/org/openapitools/model/Pet.kt | 6 ++---- .../src/main/kotlin/org/openapitools/model/Pet.kt | 6 ++---- .../src/main/kotlin/org/openapitools/model/Pet.kt | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) 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 3b7d8a1918e8..22bbe695c0dc 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 @@ -26,13 +26,11 @@ import io.swagger.annotations.ApiModelProperty */ data class Pet( - @get:NotNull @ApiModelProperty(example = "doggie", required = true, value = "") - @field:JsonProperty("name") val name: kotlin.String, + @field:JsonProperty("name", required = true) val name: kotlin.String, - @get:NotNull @ApiModelProperty(example = "null", required = true, value = "") - @field:JsonProperty("photoUrls") val photoUrls: kotlin.collections.List, + @field:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @ApiModelProperty(example = "null", value = "") @field:JsonProperty("id") val id: kotlin.Long? = null, 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 3b7d8a1918e8..22bbe695c0dc 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 @@ -26,13 +26,11 @@ import io.swagger.annotations.ApiModelProperty */ data class Pet( - @get:NotNull @ApiModelProperty(example = "doggie", required = true, value = "") - @field:JsonProperty("name") val name: kotlin.String, + @field:JsonProperty("name", required = true) val name: kotlin.String, - @get:NotNull @ApiModelProperty(example = "null", required = true, value = "") - @field:JsonProperty("photoUrls") val photoUrls: kotlin.collections.List, + @field:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @ApiModelProperty(example = "null", value = "") @field:JsonProperty("id") val id: kotlin.Long? = null, 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 3b7d8a1918e8..22bbe695c0dc 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 @@ -26,13 +26,11 @@ import io.swagger.annotations.ApiModelProperty */ data class Pet( - @get:NotNull @ApiModelProperty(example = "doggie", required = true, value = "") - @field:JsonProperty("name") val name: kotlin.String, + @field:JsonProperty("name", required = true) val name: kotlin.String, - @get:NotNull @ApiModelProperty(example = "null", required = true, value = "") - @field:JsonProperty("photoUrls") val photoUrls: kotlin.collections.List, + @field:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List, @ApiModelProperty(example = "null", value = "") @field:JsonProperty("id") val id: kotlin.Long? = null,