Recently I have updated nestjs/swagger
package in my project to ^4.0.0
. Previously Swagger serialized my query parameters as follows:
/resources?parameter=1,2,3
Now it looks like this:
/resources?parameter=1¶meter=2¶meter=3
DTO object for my query looks like this:
class QueryDTO {
@ApiProperty({
required: false,
type: [Number],
})
@IsOptional()
readonly parameter?: number[];
}
How can I change this behaviour?
I am on nestjs/swagger 4.5.9
I made it work by define the DTO ( notice the format: 'form'
)
@IsNotEmpty()
@ApiProperty({
type: [Number],
format: 'form',
})
@IsArray()
@Transform((value: string) => value.split(',').map(item => Number(item)))
@IsNumber({}, {each: true})
deviceId: Array<number>;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With