Search code examples
nestjsnestjs-swagger

ApiProperty not reflecting the type of data i want


I'm creating a POST endpoint that will receive an object with one property: returnIds. This return ids will be an array of NUMBERS

{
  "returnIds": [1, 2, 3, 4, 5]
}

For this i create this DTO

 @ApiProperty()  
 returnIds: number[]

The problem is that swagger is showing me this

enter image description here

what i need to change that the shown example is instead "string" a 0 or something related with a number?

This is my endpoint

enter image description here

Thank u a lot


Solution

  • You can use @ApiProperty({ type: [Number] }) to designate it's supposed to be an array of numbers. Just like it's mentioned in the docs