I am trying to add summary in my swagger documentation routes but I am not able to find the appropriate decorator for defining the summary.
There are some routes in which I have not specified any DTO's. So, I would like to manually add request body for that endpoint.
user.controller.ts
@Controller('users')
@ApiTags('User')
@ApiBearerAuth()
export class UsersController {
constructor(private readonly service: UsersService) {}
@Get()
async findAll() {
const data = await this.service.findAll();
return {
statusCode: 200,
message: 'Users retrieved successfully',
data,
};
}
}
auth.controller.ts
@UseGuards(AuthGuard('local'))
@Post('login')
@ApiParam({
name: 'email',
type: 'string'
})
@ApiParam({
name: 'password',
type: 'string'
})
async login(@Request() req) {
return this.authService.login(req.user);
}
This module is for the Play 1. x series only. Creates a self-documenting meta-description for REST APIs which allows for code-gen, UI-sandbox, and test framework. See more at http://swagger.wordnik.com and at http://developer.wordnik.com/docs.
For Endpoint Summary, you can use @ApiOperation()
. For schema, you can use @ApiResponse()
@Get()
@ApiOperation({ summary: 'summary goes here' })
@ApiResponse({ status: 200, description: 'description goes here', schema: { ...define schema here... } })
async findAll() {}
Read more about Raw Definitions from the documentations here: https://docs.nestjs.com/recipes/swagger#raw-definitions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With