7

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.

Gerriet
  • 1,302
  • 14
  • 20
  • 4
    This functionality doesn't exist. There's an open PR adding a class decorator, but it's only adding "name". I'd recommend you open an issue there, or contribute with a PR if this is something you need. PR here: https://github.com/nestjs/swagger/pull/983 – HMilbradt Oct 07 '21 at 15:39
  • 1
    @HMilbradt Thanks for the information. I created an issue for this: https://github.com/nestjs/swagger/issues/1596 – Gerriet Oct 08 '21 at 09:33

1 Answers1

-1

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

Youba
  • 2,636
  • 3
  • 11
  • 25
  • 2
    That is for documenting the properties that are part of the dto. But OpenAPI also has a description for the complete schema, that is what I am searching for. – Gerriet Oct 07 '21 at 13:37