When I send only one parameter, I got query result like string, not like string[]. This happened only from UI swagger, if I send from Postman - it works good.
I just want send from swagger-ui one parameter and got array of strings, not a single string.
How I can fix it? Help me please.
Example1: send one parameter and in my controller I got string like '25'
Example2: when I send 2 parameters in controller I can see array of strings ('25', '21')
export class List {
@ApiProperty({ isArray: true, type: String, required: false })
@IsOptional()
public categories?: string[];
}
when you fill a single category the query param will be translated as a string while when you fill in several categories understand it as a array.
to solve this problem I added in DTO :
@Transform(({ value }) => (Array.isArray(value) ? value : Array(value)))
I force the cast to array