> 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)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/nestjs-documentation?format=md"OpenAPI & Documentation
Priority: P2 (MAINTENANCE)
Automated API documentation and OpenAPI standards.
- Automation: ALWAYS use the Nest CLI Plugin (
@nestjs/swagger/plugin).- Benefit: Auto-generates
@ApiPropertyfor DTOs and response types. Reduces boilerplate by 50%. - Config:
nest-cli.json->"plugins": ["@nestjs/swagger"].
- Benefit: Auto-generates
- Versioning: Maintain separate Swagger docs for
v1,v2if breaking changes occur.
Response Documentation
- Strictness: Every controller method must have
@ApiResponse({ status: 200, type: UserDto }). - Generic Wrappers: Define
ApiPaginatedResponse<T>decorators to document genericPageDto<T>returns properly (Swagger doesn't handle generics well by default).- Technique: Use
ApiExtraModels+getSchemaPath()in the custom decorator to handle the genericTref.
- Technique: Use
Advanced Patterns
- Polymorphism: Use
@ApiExtraModelsandgetSchemaPathforoneOf/anyOfunion types. - File Uploads: Document
multipart/form-dataexplicitly.- 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:
@ApiBearerAuth()or@ApiSecurity('api-key')(Must matchDocumentBuilder().addBearerAuth()).
- Types:
- Enums: Force named enums for reusable schema references.
- Code:
@ApiProperty({ enum: MyEnum, enumName: 'MyEnum' }).
- Code:
Operation Grouping
-
Tags: Mandatory
@ApiTags('domains')on every Controller to group endpoints logically. -
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
@compodoc/compodocto generate static documentation of the module graph, services, and dependencies.- Use Case: New developer onboarding and architectural review.
Advanced OpenAPI
- Polymorphism: Use
@ApiExtraModelsandgetSchemaPathforoneOf/anyOfunion types.- Pattern: Register generic/sub-types in controller, refer via schema
$ref.
- Pattern: Register generic/sub-types in controller, refer via schema
- File Uploads: Document
multipart/form-dataexplicitly.- 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:
@ApiBearerAuth()or@ApiSecurity('api-key'). Match setup inDocumentBuilder.
- Types:
- Enums: Force named enums for reusable schema references.
- Code:
@ApiProperty({ enum: MyEnum, enumName: 'MyEnum' }).
- Code:
- Grouping: Segregate public vs. internal docs.
- Setup:
SwaggerModule.createDocument(app, config, { include: [AdminModule] }).
- Setup:
🚫 Anti-Patterns
- Do NOT use standard patterns if specific project rules exist.
- Do NOT ignore error handling or edge cases.
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)