Is there an existing issue for this?
Current behavior
My sort param is used like ?sort[][created_on]=desc so I desire some openapi json like
"/some-endpoint": {
"get": {
"operationId": "SomeController_list",
"parameters": [
{
"required": false,
"name": "sort",
"in": "query",
"schema": {
"example": [ { "created_on": "desc" } ],
"type": "array",
"items": {
"type": "object",
"additionalProperties": { "type": "string", "enum": [ "asc", "desc" ] }
}
}
}
]
}
},
but instead, nestjs/swagger is generating the get.paramaters[0].schema with an incorrect schema for the items field
{
"required": false,
"name": "sort",
"in": "query",
"schema": {
"default": [ { "created_on": "desc" } ],
"example": [ { "created_on": "desc" } ],
"type": "array",
"items": { "type": "array" }
}
}
In my case I am using @anatine/zod-openapi in combination with @nestjs/swagger to generate the docs; I am not using decorators besides @ApiQuery({ type: SomeClass }) where SomeClass is generated by a zod plugin. As I explain below, this issue does appear to be with @nestjs/swagger though, not the zod plugin.
I can see that the correct metadata gets passed to transformToArraySchemaProperty:
{
"type": "array",
"items": {
"type": "object",
"additionalProperties": {
"type": "string",
"enum": ["asc", "desc"]
}
},
"example": [{ "created_on": "desc" }],
"required": false,
"isArray": true
}
and that on line 550 that type is literally the string 'array' so the first part of the ternary is used, whereas I need the 2nd part of the ternary to be used.
Minimum reproduction code
https://github.com/nestjs/swagger
Steps to reproduce
No response
Expected behavior
The transformToArraySchemaProperty method correctly sets the items schema.
Package version
11.2.1
NestJS version
11.1.8
Node.js version
v22.16.0
In which operating systems have you tested?
Other
No response
Is there an existing issue for this?
Current behavior
My sort param is used like
?sort[][created_on]=descso I desire some openapi json likebut instead, nestjs/swagger is generating the
get.paramaters[0].schemawith an incorrect schema for theitemsfield{ "required": false, "name": "sort", "in": "query", "schema": { "default": [ { "created_on": "desc" } ], "example": [ { "created_on": "desc" } ], "type": "array", "items": { "type": "array" } } }In my case I am using
@anatine/zod-openapiin combination with@nestjs/swaggerto generate the docs; I am not using decorators besides@ApiQuery({ type: SomeClass })where SomeClass is generated by a zod plugin. As I explain below, this issue does appear to be with @nestjs/swagger though, not the zod plugin.I can see that the correct metadata gets passed to transformToArraySchemaProperty:
{ "type": "array", "items": { "type": "object", "additionalProperties": { "type": "string", "enum": ["asc", "desc"] } }, "example": [{ "created_on": "desc" }], "required": false, "isArray": true }and that on line 550 that
typeis literally the string'array'so the first part of the ternary is used, whereas I need the 2nd part of the ternary to be used.Minimum reproduction code
https://github.com/nestjs/swagger
Steps to reproduce
No response
Expected behavior
The
transformToArraySchemaPropertymethod correctly sets theitemsschema.Package version
11.2.1
NestJS version
11.1.8
Node.js version
v22.16.0
In which operating systems have you tested?
Other
No response