Skillshub nestjs-documentation
Swagger automation and Generic response documentation. Use when generating OpenAPI/Swagger documentation or documenting NestJS API responses. (triggers: main.ts, **/*.dto.ts, DocumentBuilder, SwaggerModule, ApiProperty, ApiResponse)
install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/HoangNguyen0403/agent-skills-standard/nestjs-documentation" ~/.claude/skills/comeonoliver-skillshub-nestjs-documentation && rm -rf "$T"
manifest:
skills/HoangNguyen0403/agent-skills-standard/nestjs-documentation/SKILL.mdsource content
OpenAPI & Documentation
Priority: P2 (MAINTENANCE)
Automated API documentation and OpenAPI standards.
- Automation: ALWAYS use the Nest CLI Plugin (
).@nestjs/swagger/plugin- Benefit: Auto-generates
for DTOs and response types. Reduces boilerplate by 50%.@ApiProperty - Config:
->nest-cli.json
."plugins": ["@nestjs/swagger"]
- Benefit: Auto-generates
- Versioning: Maintain separate Swagger docs for
,v1
if breaking changes occur.v2
Response Documentation
- Strictness: Every controller method must have
.@ApiResponse({ status: 200, type: UserDto }) - Generic Wrappers: Define
decorators to document genericApiPaginatedResponse<T>
returns properly (Swagger doesn't handle generics well by default).PageDto<T>- Technique: Use
+ApiExtraModels
in the custom decorator to handle the genericgetSchemaPath()
ref.T
- Technique: Use
Advanced Patterns
- Polymorphism: Use
and@ApiExtraModels
forgetSchemaPath
/oneOf
union types.anyOf - File Uploads: Document
explicitly.multipart/form-data- Decorator:
.@ApiConsumes('multipart/form-data') - Body:
.@ApiBody({ schema: { type: 'object', properties: { file: { type: 'string', format: 'binary' } } } })
- Decorator:
- Authentication: Specify granular security schemes per route/controller.
- Types:
or@ApiBearerAuth()
(Must match@ApiSecurity('api-key')
).DocumentBuilder().addBearerAuth()
- Types:
- Enums: Force named enums for reusable schema references.
- Code:
.@ApiProperty({ enum: MyEnum, enumName: 'MyEnum' })
- Code:
Operation Grouping
-
Tags: Mandatory
on every Controller to group endpoints logically.@ApiTags('domains') -
Multiple Docs: generate separate docs for different audiences (e.g. Public vs Internal).
SwaggerModule.createDocument(app, config, { include: [PublicModule] }); // /api/docs SwaggerModule.createDocument(app, adminConfig, { include: [AdminModule] }); // /admin/docs
Self-Documentation
- Compodoc: Use
to generate static documentation of the module graph, services, and dependencies.@compodoc/compodoc- Use Case: New developer onboarding and architectural review.
Anti-Patterns
- No missing @ApiResponse: Every controller method must declare its response type and status code.
- No /docs in production: Disable Swagger in production to prevent API schema exposure.
- No manual @ApiProperty everywhere: Use the Nest CLI Swagger plugin to auto-generate from DTOs.