I'm using Spring boot + webflux + r2dbc to implement an REST API Server.
The generated schema for a model is duplicating the same field with different definition (name, restrictions, etc.).
My model:
data class Extension(
@Column("number")
@JsonProperty("number", required = true)
@Pattern(regexp = "^[0-9]{6,}\$")
@Schema(description = "The number", example = "12345007100")
val number: String,
@Column("tenant_id")
@JsonProperty("tenant_id", required = true)
@Pattern(regexp = "^[0-9]{5}\$")
@Schema(name = "tenant_id", description = "The ID of the Tenant", example = "12345")
val tenantId: String,
)
Router
@Bean
fun extensionsRoutes(): RouterFunction<ServerResponse> {
return SpringdocRouteBuilder.route()
.GET(
path("/extensions").and(accept(MediaType.APPLICATION_JSON)),
handler::getAll
) { ops ->
ops
.tag(tag)
.operationId("operation id")
.summary("summary")
.description("description")
.response(
responseBuilder()
.responseCode("200")
.description("The list of all Extensions")
.implementationArray(Extension::class.java)
)
}
The generated OpenAPI schema for Extension
model
Extension:
required:
- number
type: object
properties:
number:
pattern: "^[0-9]{6,}$"
type: string
description: The number
example: "12345007100"
tenant_id:
pattern: "^[0-9]{5}$"
type: string
description: The ID of the Tenant to which the Extension belongs
writeOnly: true
example: "12345"
tenantId:
type: string
I've two fields: tenant_id and tenantId but this is the same field in the model. Also note that the definition for tenantId ignores schema properties (like the required and pattern properties).
I'm missing some annotation ? Seems that i'm missing some annotation to indicate springdoc library that the field is already in definition.