swagger-core
swagger-core copied to clipboard
Redundant nested array rendered when using @SchemaProperty(array = ...) with object schemas
@SchemaProperty(name = "create", array = @ArraySchema(schema = @Schema(implementation = String.class)))
renders as:
"create": {
"type": "array",
"items": {
"type": "string"
}
}
@SchemaProperty(name = "create", schema = @Schema(implementation = MyCustomDto.class))
renders as:
"create": {
"$ref": "#/components/schemas/MyCustomDto"
}
All of the above to be expected.
However, @SchemaProperty(name = "create", array = @ArraySchema(schema = @Schema(implementation = MyCustomDto.class)))
renders as:
"create": {
"type": "array",
"items": {
"type": "array",
"items": {
"$ref": "#/components/schemas/MyCustomDto"
}
}
}
In other words, it would seem there is no way to obtain a flat array property with POJO elements, using @SchemaProperty. It's either a plain object schema or a nested array, no in-between.