Decorators for Controllers and HTTP Responses
Last updated
Was this helpful?
Last updated
Was this helpful?
To document your controllers and HTTP responses you can use the following decorators:
@ApiTags
@ApiResponse
To document your controllers and separate them from others, you can use the @ApiTags property:
By using @ApiTags on different controllers you can separate all endpoints via the tag you declared.
Example:
By not using the @ApiTags property in your controllers, they will be grouped under the default tag.
To document the responses of each of your endpoints, you can use the @ApiResponse decorator. For example, if there is a response that can occur on any endpoint, you can use this decorator at the controller level, so that all endpoints inherit this property:
You can use the following properties for the @ApiResponse decorator:
status: HTTP code of the response.
type: If you have a class where you have defined the response, here you can place the class name.
Example:
description: you can use this field to give a brief description of the endpoint.
schema: if you don't have a class with the response defined or you use dynamic messages, your best bet is to declare the response example in the schema field.
You can see the configuration of the NotificationCategories
class .