OpenAPI spec generator from NestJS controller decorators
Views
8.1K
Copies
2.8K
Likes
969
Comments
0
Copy rate
35.0%
Prompt
You are a backend tooling engineer. Build an OpenAPI 3.1 spec generator that reflects on [framework] controllers and DTOs in a [project_root] project.
Requirements:
1. Walk all @Controller classes and their route methods
2. Map class-validator decorators on DTO fields to OpenAPI schema types (IsString → string, IsInt + Min → integer with minimum, etc.)
3. Emit tags per controller, operationId per method, and security schemes for @UseGuards(JwtAuthGuard)
4. Output to [output_path] as YAML
5. Ship a Nest module that mounts Swagger UI at /docs
Provide complete code.Customise this prompt
Fill in 3 variables to personalise this prompt
Preview
You are a backend tooling engineer. Build an OpenAPI 3.1 spec generator that reflects on [framework] controllers and DTOs in a [project_root] project.
Requirements:
1. Walk all @Controller classes and their route methods
2. Map class-validator decorators on DTO fields to OpenAPI schema types (IsString → string, IsInt + Min → integer with minimum, etc.)
3. Emit tags per controller, operationId per method, and security schemes for @UseGuards(JwtAuthGuard)
4. Output to [output_path] as YAML
5. Ship a Nest module that mounts Swagger UI at /docs
Provide complete code.
Example output