swagger
swagger copied to clipboard
[@nestjs/swagger v7] oneOf doesn't work as expected
Did you read the migration guide?
- [X] I have read the whole migration guide
Is there an existing issue that is already proposing this?
- [X] I have searched the existing issues
Potential Commit/PR that introduced the regression
No response
Versions
6 -> 7.4.0
Describe the regression
@ApiProperty({
type: undefined,
oneOf: [
{ type: 'array', items: { type: 'string' } },
{ type: 'array', items: { type: 'number' } },
{ type: 'array', items: { type: 'boolean' } },
],
description: API_DESCRIPTION,
})
values: string[] | number[] | boolean[]
this configuration used to produce this schema in v6
"values": {
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "array",
"items": {
"type": "number"
}
},
{
"type": "array",
"items": {
"type": "boolean"
}
}
]
}
in v7 for some reason type: array
is added and oneOf
suddenly defines items not schema of "values"
Minimum reproduction code
@ApiProperty({
type: undefined,
oneOf: [
{ type: 'array', items: { type: 'string' } },
{ type: 'array', items: { type: 'number' } },
{ type: 'array', items: { type: 'boolean' } },
],
description: API_DESCRIPTION,
})
values: string[] | number[] | boolean[]
Expected behavior
I expect to see this schema to be generated:
"values": {
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "array",
"items": {
"type": "number"
}
},
{
"type": "array",
"items": {
"type": "boolean"
}
}
]
}
Other
No response