Gerriet
Gerriet

Reputation: 1350

How do I add a description for a schema (dto) in Swagger for Nestjs?

I would like to add a description field to my dto (also to satisfy no_schema_description in OpenAPI linting), but find no way to do so. Which decorator to use? At the point of defining the dto or in the response?

Update (clarify): I am looking to define a description for the whole schema, not for single properties.

Upvotes: 8

Views: 3924

Answers (1)

Ayoub Touba
Ayoub Touba

Reputation: 3007

You can do that simply by using ApiProperty():

@ApiProperty({
  description: 'The age of a cat',
})
age: number;

I recommend you to check the official doc openapi/types-and-parameters

Upvotes: 0

Related Questions