Decorators for Requests and Responses
Last updated
Last updated
To document your requests and responses you can use the following decorators:
@ApiProperty
@ApiPropertyOptional
By using these decorators on each of the class properties, you have to document each of them.
This is an example of what a documented request body looks like:
If you want to document your API responses, you should also use decorators to make them visible in the Swagger interface.
Example:
If you use child classes in a parent class, the child classes must be declared before the parent class.
To use Swagger decorators, you must always use a JavaScript class.
✅ Correct:
❌ Incorrect: