swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Redundant nested array rendered when using @SchemaProperty(array = ...) with object schemas

Open crizzis opened this issue 11 months ago • 1 comments

@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.

crizzis avatar Nov 15 '24 09:11 crizzis