swagger-api / swagger-api/swagger-core
Redundant nested array rendered when using @SchemaProperty(array = ...) with object schemas
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7.5k
- Forks
- 2.3k
- Avg merge
- 18h 1m
- Merged PRs (30d)
- 10
Description
@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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how @SchemaProperty combines with @ArraySchema and the MyCustomDto implementation in the OpenAPI schema generation path. Reproduce the reported annotation cases and compare the generated schemas; done means the POJO case produces one array whose items reference MyCustomDto rather than a nested array.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100