soon530 / nestjs-study

來學一下nestjs吧!
0 stars 0 forks source link

解析dto參數 #15

Open soon530 opened 2 years ago

soon530 commented 2 years ago

本來是空的,在dto加上@ApiProperty()就會出現了。

image
soon530 commented 2 years ago

沒加@ApiProperty()不會在Swagger出現而已,對程式的運作沒有影響。

soon530 commented 2 years ago

可以加一些說明跟限制條件。

    @ApiProperty({
        maxLength: 20,
        description: 'Todo 的標題',
    })
    public readonly title: string;
image
soon530 commented 2 years ago

不過,限制條件只是說說而已,超過顯然不會怎樣 XD

{
  "title": "1234567890 1234567890 1234567890",
  "description": "string"
}
image