Skip to content

Commit

Permalink
[kotlin-spring] Move Jackson annotation from field to getter (OpenAPI…
Browse files Browse the repository at this point in the history
…Tools#10825)

* Move Jackson annotation from field to getter

In some case, Jackson will duplicate entries when the annotation is on field
See FasterXML/jackson-databind#1609

* Update samples
  • Loading branch information
juherr authored Jan 2, 2023
1 parent b8b8c5c commit 921199b
Show file tree
Hide file tree
Showing 44 changed files with 191 additions and 191 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
@Schema({{#example}}example = "{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{.}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{/example}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}description = "{{{description}}}"){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}
@ApiModelProperty({{#example}}example = "{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{.}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{/example}}{{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swagger1AnnotationLibrary}}{{#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}}null{{/defaultValue}}
@get:JsonProperty("{{{baseName}}}"){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{{nameInCamelCase}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}? = {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{#useBeanValidation}}{{>beanValidation}}{{>beanValidationModel}}{{/useBeanValidation}}{{#swagger2AnnotationLibrary}}
@Schema({{#example}}example = "{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{.}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{/example}}required = true, {{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}description = "{{{description}}}"){{/swagger2AnnotationLibrary}}{{#swagger1AnnotationLibrary}}
@ApiModelProperty({{#example}}example = "{{#lambdaRemoveLineBreak}}{{#lambdaEscapeDoubleQuote}}{{{.}}}{{/lambdaEscapeDoubleQuote}}{{/lambdaRemoveLineBreak}}", {{/example}}required = true, {{#isReadOnly}}readOnly = {{{isReadOnly}}}, {{/isReadOnly}}value = "{{{description}}}"){{/swagger1AnnotationLibrary}}
@field:JsonProperty("{{{baseName}}}", required = true){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{{nameInCamelCase}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isReadOnly}}?{{/isReadOnly}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{#isReadOnly}}{{^defaultValue}} = null{{/defaultValue}}{{/isReadOnly}}
@get:JsonProperty("{{{baseName}}}", required = true){{#isInherited}} override{{/isInherited}} {{>modelMutable}} {{{name}}}: {{#isEnum}}{{#isArray}}{{baseType}}<{{/isArray}}{{classname}}.{{{nameInCamelCase}}}{{#isArray}}>{{/isArray}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isReadOnly}}?{{/isReadOnly}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{#isReadOnly}}{{^defaultValue}} = null{{/defaultValue}}{{/isReadOnly}}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import io.swagger.v3.oas.annotations.media.Schema
data class Category(

@Schema(example = "null", description = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@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:JsonProperty("name") val name: kotlin.String? = null
@get:JsonProperty("name") val name: kotlin.String? = null
) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import io.swagger.v3.oas.annotations.media.Schema
data class ModelApiResponse(

@Schema(example = "null", description = "")
@field:JsonProperty("code") val code: kotlin.Int? = null,
@get:JsonProperty("code") val code: kotlin.Int? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("type") val type: kotlin.String? = null,
@get:JsonProperty("type") val type: kotlin.String? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("message") val message: kotlin.String? = null
@get:JsonProperty("message") val message: kotlin.String? = null
) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ import io.swagger.v3.oas.annotations.media.Schema
data class Order(

@Schema(example = "null", description = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@get:JsonProperty("id") val id: kotlin.Long? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("petId") val petId: kotlin.Long? = null,
@get:JsonProperty("petId") val petId: kotlin.Long? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("quantity") val quantity: kotlin.Int? = null,
@get:JsonProperty("quantity") val quantity: kotlin.Int? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null,
@get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null,

@Schema(example = "null", description = "Order Status")
@field:JsonProperty("status") val status: Order.Status? = null,
@get:JsonProperty("status") val status: Order.Status? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("complete") val complete: kotlin.Boolean? = false
@get:JsonProperty("complete") val complete: kotlin.Boolean? = false
) {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ import io.swagger.v3.oas.annotations.media.Schema
data class Pet(

@Schema(example = "doggie", required = true, description = "")
@field:JsonProperty("name", required = true) val name: kotlin.String,
@get:JsonProperty("name", required = true) val name: kotlin.String,

@Schema(example = "null", required = true, description = "")
@field:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List<kotlin.String>,
@get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List<kotlin.String>,

@Schema(example = "null", description = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@get:JsonProperty("id") val id: kotlin.Long? = null,

@field:Valid
@Schema(example = "null", description = "")
@field:JsonProperty("category") val category: Category? = null,
@get:JsonProperty("category") val category: Category? = null,

@field:Valid
@Schema(example = "null", description = "")
@field:JsonProperty("tags") val tags: kotlin.collections.List<Tag>? = null,
@get:JsonProperty("tags") val tags: kotlin.collections.List<Tag>? = null,

@Schema(example = "null", description = "pet status in the store")
@Deprecated(message = "")
@field:JsonProperty("status") val status: Pet.Status? = null
@get:JsonProperty("status") val status: Pet.Status? = null
) {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import io.swagger.v3.oas.annotations.media.Schema
data class Tag(

@Schema(example = "null", description = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@get:JsonProperty("id") val id: kotlin.Long? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("name") val name: kotlin.String? = null
@get:JsonProperty("name") val name: kotlin.String? = null
) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ import io.swagger.v3.oas.annotations.media.Schema
data class User(

@Schema(example = "null", description = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@get:JsonProperty("id") val id: kotlin.Long? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("username") val username: kotlin.String? = null,
@get:JsonProperty("username") val username: kotlin.String? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("firstName") val firstName: kotlin.String? = null,
@get:JsonProperty("firstName") val firstName: kotlin.String? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("lastName") val lastName: kotlin.String? = null,
@get:JsonProperty("lastName") val lastName: kotlin.String? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("email") val email: kotlin.String? = null,
@get:JsonProperty("email") val email: kotlin.String? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("password") val password: kotlin.String? = null,
@get:JsonProperty("password") val password: kotlin.String? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("phone") val phone: kotlin.String? = null,
@get:JsonProperty("phone") val phone: kotlin.String? = null,

@Schema(example = "null", description = "User Status")
@field:JsonProperty("userStatus") val userStatus: kotlin.Int? = null
@get:JsonProperty("userStatus") val userStatus: kotlin.Int? = null
) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import io.swagger.v3.oas.annotations.media.Schema
data class Category(

@Schema(example = "null", description = "")
@field:JsonProperty("id") var id: kotlin.Long? = null,
@get:JsonProperty("id") var id: kotlin.Long? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("name") var name: kotlin.String? = null
@get:JsonProperty("name") var name: kotlin.String? = null
) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import io.swagger.v3.oas.annotations.media.Schema
data class ModelApiResponse(

@Schema(example = "null", description = "")
@field:JsonProperty("code") var code: kotlin.Int? = null,
@get:JsonProperty("code") var code: kotlin.Int? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("type") var type: kotlin.String? = null,
@get:JsonProperty("type") var type: kotlin.String? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("message") var message: kotlin.String? = null
@get:JsonProperty("message") var message: kotlin.String? = null
) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ import io.swagger.v3.oas.annotations.media.Schema
data class Order(

@Schema(example = "null", description = "")
@field:JsonProperty("id") var id: kotlin.Long? = null,
@get:JsonProperty("id") var id: kotlin.Long? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("petId") var petId: kotlin.Long? = null,
@get:JsonProperty("petId") var petId: kotlin.Long? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("quantity") var quantity: kotlin.Int? = null,
@get:JsonProperty("quantity") var quantity: kotlin.Int? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("shipDate") var shipDate: java.time.OffsetDateTime? = null,
@get:JsonProperty("shipDate") var shipDate: java.time.OffsetDateTime? = null,

@Schema(example = "null", description = "Order Status")
@field:JsonProperty("status") var status: Order.Status? = null,
@get:JsonProperty("status") var status: Order.Status? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("complete") var complete: kotlin.Boolean? = false
@get:JsonProperty("complete") var complete: kotlin.Boolean? = false
) {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ import io.swagger.v3.oas.annotations.media.Schema
data class Pet(

@Schema(example = "doggie", required = true, description = "")
@field:JsonProperty("name", required = true) var name: kotlin.String,
@get:JsonProperty("name", required = true) var name: kotlin.String,

@Schema(example = "null", required = true, description = "")
@field:JsonProperty("photoUrls", required = true) var photoUrls: kotlin.collections.MutableList<kotlin.String>,
@get:JsonProperty("photoUrls", required = true) var photoUrls: kotlin.collections.MutableList<kotlin.String>,

@Schema(example = "null", description = "")
@field:JsonProperty("id") var id: kotlin.Long? = null,
@get:JsonProperty("id") var id: kotlin.Long? = null,

@field:Valid
@Schema(example = "null", description = "")
@field:JsonProperty("category") var category: Category? = null,
@get:JsonProperty("category") var category: Category? = null,

@field:Valid
@Schema(example = "null", description = "")
@field:JsonProperty("tags") var tags: kotlin.collections.MutableList<Tag>? = null,
@get:JsonProperty("tags") var tags: kotlin.collections.MutableList<Tag>? = null,

@Schema(example = "null", description = "pet status in the store")
@field:JsonProperty("status") var status: Pet.Status? = null
@get:JsonProperty("status") var status: Pet.Status? = null
) {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import io.swagger.v3.oas.annotations.media.Schema
data class Tag(

@Schema(example = "null", description = "")
@field:JsonProperty("id") var id: kotlin.Long? = null,
@get:JsonProperty("id") var id: kotlin.Long? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("name") var name: kotlin.String? = null
@get:JsonProperty("name") var name: kotlin.String? = null
) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ import io.swagger.v3.oas.annotations.media.Schema
data class User(

@Schema(example = "null", description = "")
@field:JsonProperty("id") var id: kotlin.Long? = null,
@get:JsonProperty("id") var id: kotlin.Long? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("username") var username: kotlin.String? = null,
@get:JsonProperty("username") var username: kotlin.String? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("firstName") var firstName: kotlin.String? = null,
@get:JsonProperty("firstName") var firstName: kotlin.String? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("lastName") var lastName: kotlin.String? = null,
@get:JsonProperty("lastName") var lastName: kotlin.String? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("email") var email: kotlin.String? = null,
@get:JsonProperty("email") var email: kotlin.String? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("password") var password: kotlin.String? = null,
@get:JsonProperty("password") var password: kotlin.String? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("phone") var phone: kotlin.String? = null,
@get:JsonProperty("phone") var phone: kotlin.String? = null,

@Schema(example = "null", description = "User Status")
@field:JsonProperty("userStatus") var userStatus: kotlin.Int? = null
@get:JsonProperty("userStatus") var userStatus: kotlin.Int? = null
) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import io.swagger.v3.oas.annotations.media.Schema
data class Category(

@Schema(example = "null", description = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@get:JsonProperty("id") val id: kotlin.Long? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("name") val name: kotlin.String? = null
@get:JsonProperty("name") val name: kotlin.String? = null
) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import io.swagger.v3.oas.annotations.media.Schema
data class ModelApiResponse(

@Schema(example = "null", description = "")
@field:JsonProperty("code") val code: kotlin.Int? = null,
@get:JsonProperty("code") val code: kotlin.Int? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("type") val type: kotlin.String? = null,
@get:JsonProperty("type") val type: kotlin.String? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("message") val message: kotlin.String? = null
@get:JsonProperty("message") val message: kotlin.String? = null
) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ import io.swagger.v3.oas.annotations.media.Schema
data class Order(

@Schema(example = "null", description = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@get:JsonProperty("id") val id: kotlin.Long? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("petId") val petId: kotlin.Long? = null,
@get:JsonProperty("petId") val petId: kotlin.Long? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("quantity") val quantity: kotlin.Int? = null,
@get:JsonProperty("quantity") val quantity: kotlin.Int? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null,
@get:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null,

@Schema(example = "null", description = "Order Status")
@field:JsonProperty("status") val status: Order.Status? = null,
@get:JsonProperty("status") val status: Order.Status? = null,

@Schema(example = "null", description = "")
@field:JsonProperty("complete") val complete: kotlin.Boolean? = false
@get:JsonProperty("complete") val complete: kotlin.Boolean? = false
) {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ import io.swagger.v3.oas.annotations.media.Schema
data class Pet(

@Schema(example = "doggie", required = true, description = "")
@field:JsonProperty("name", required = true) val name: kotlin.String,
@get:JsonProperty("name", required = true) val name: kotlin.String,

@Schema(example = "null", required = true, description = "")
@field:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List<kotlin.String>,
@get:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List<kotlin.String>,

@Schema(example = "null", description = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@get:JsonProperty("id") val id: kotlin.Long? = null,

@field:Valid
@Schema(example = "null", description = "")
@field:JsonProperty("category") val category: Category? = null,
@get:JsonProperty("category") val category: Category? = null,

@field:Valid
@Schema(example = "null", description = "")
@field:JsonProperty("tags") val tags: kotlin.collections.List<Tag>? = null,
@get:JsonProperty("tags") val tags: kotlin.collections.List<Tag>? = null,

@Schema(example = "null", description = "pet status in the store")
@field:JsonProperty("status") val status: Pet.Status? = null
@get:JsonProperty("status") val status: Pet.Status? = null
) {

/**
Expand Down
Loading

0 comments on commit 921199b

Please sign in to comment.