API metadata decorators
If you work through any Nest.js project and properly decorate all the controllers and controller methods with the decorators we have covered so far, the swagger document the Nest.js swagger module produces will have every technical detail a user of the APIs would need to understand and use the APIs. The last two decorators we will cover in this chapter simply provide more metadata for the swagger document. The swagger UI will use this metadata to produce a cleaner UI, but functionality will not change.
The first decorator we will cover is @ApiOperation
. Don’t confuse this decorator with the HTTP method decorators like @Put
. This decorator is used to provide a title, description, and unique identifier called an operationId for individual controller methods.
@
Put
(
'comments/:commentId'
)
@
ApiOperation
({
title
:
'Comment Update'
,
description
:
'Updates a specific comment with new content'
,
operationId
:
'commentUpdate...