Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add description to @ApiTags for swagger in NestJS?

Tags:

swagger

nestjs

I want to add desription for block of api.

I have tried:

@ApiOperation({
  description: 'Operation description'
})

It doesn't work.

like image 868
Vladimir Golub Avatar asked Oct 26 '25 19:10

Vladimir Golub


2 Answers

Adding description on method level

@ApiOperation({ summary: 'Operation description' })

Check here: https://docs.nestjs.com/openapi/migration-guide#breaking-changes

Adding tag on class level (controller)

@ApiTags('MyTag')

This will create a collapsible block with all methods underneath it.

Check here: https://docs.nestjs.com/openapi/decorators

like image 63
Tim Avatar answered Oct 29 '25 09:10

Tim


To improve previous answer: You can add tag description on initial step

new DocumentBuilder()
.setTitle('API with NestJS')
...
.addTag('SomeTag1', 'Tag description 1')
.addTag('SomeTag2', 'Tag description 2')

And then use tag on class level (controller)

@ApiTags('SomeTag1')
like image 43
Gopard Avatar answered Oct 29 '25 09:10

Gopard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!