I've the following dto:
export class CreatePersonDto {
@IsString()
@ApiProperty({
description: 'Person name',
example: 'Jhon Doe',
})
readonly name: string;
@ValidateIf((object, value) => value)
@IsString({ each: true })
@ApiProperty({
description: 'Clothes ids',
isArray: true,
type: String,
})
readonly clothes: string[];
}
This is the cURL generated by Swagger Ui: (Unable to parse this in NestJs to a string array)
curl -X 'POST' \
'http://localhost:3000/person' \
-H 'accept: */*' \
-H 'Content-Type: multipart/form-data' \
-F 'name=Jhon Doe' \
-F 'clothes=id1,id2'
(Clothes are sent as a string)
The array form in the UI looks like this:
This is the expected cURL (Generated by postman, or manually): (Nestjs automatically parse this to an array)
curl -X 'POST' \
'http://localhost:3000/person' \
-H 'accept: */*' \
-H 'Content-Type: multipart/form-data' \
-F 'name=Jhon Doe' \
-F 'clothes[0]=id1' \
-F 'clothes[1]=id2'
(Clothes are correctly send as an array)
How can i solve this problem with swagger?