What is the @nestjs/swagger module?
Answer
The @nestjs/swagger module automatically generates interactive Swagger/OpenAPI documentation for your NestJS REST API. Setup in main.ts: create a DocumentBuilder config, then SwaggerModule.setup('api', app, document). It reads TypeScript types, DTOs decorated with class-validator decorators, and additional decorators like @ApiProperty(), @ApiOperation(), @ApiResponse(), and @ApiBearerAuth(). DTO properties with class-validator decorators are automatically reflected in the schema. This eliminates the need to manually maintain API documentation. The generated UI at /api is interactive — you can test endpoints directly in the browser. The OpenAPI spec can also be exported as JSON for use with other tools.
Previous
What is NestJS middleware vs guards vs interceptors?
Next
How do you create a custom decorator in NestJS?