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

Viewed 1256

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.

1 Answers

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

Related