$npx -y skills add github/awesome-copilot --skill aspnet-minimal-api-openapiCreate ASP.NET Minimal API endpoints with proper OpenAPI documentation
| 1 | # ASP.NET Minimal API with OpenAPI |
| 2 | |
| 3 | Your goal is to help me create well-structured ASP.NET Minimal API endpoints with correct types and comprehensive OpenAPI/Swagger documentation. |
| 4 | |
| 5 | ## API Organization |
| 6 | |
| 7 | - Group related endpoints using `MapGroup()` extension |
| 8 | - Use endpoint filters for cross-cutting concerns |
| 9 | - Structure larger APIs with separate endpoint classes |
| 10 | - Consider using a feature-based folder structure for complex APIs |
| 11 | |
| 12 | ## Request and Response Types |
| 13 | |
| 14 | - Define explicit request and response DTOs/models |
| 15 | - Create clear model classes with proper validation attributes |
| 16 | - Use record types for immutable request/response objects |
| 17 | - Use meaningful property names that align with API design standards |
| 18 | - Apply `[Required]` and other validation attributes to enforce constraints |
| 19 | - Use the ProblemDetailsService and StatusCodePages to get standard error responses |
| 20 | |
| 21 | ## Type Handling |
| 22 | |
| 23 | - Use strongly-typed route parameters with explicit type binding |
| 24 | - Use `Results<T1, T2>` to represent multiple response types |
| 25 | - Return `TypedResults` instead of `Results` for strongly-typed responses |
| 26 | - Leverage C# 10+ features like nullable annotations and init-only properties |
| 27 | |
| 28 | ## OpenAPI Documentation |
| 29 | |
| 30 | - Use the built-in OpenAPI document support added in .NET 9 |
| 31 | - Define operation summary and description |
| 32 | - Add operationIds using the `WithName` extension method |
| 33 | - Add descriptions to properties and parameters with `[Description()]` |
| 34 | - Set proper content types for requests and responses |
| 35 | - Use document transformers to add elements like servers, tags, and security schemes |
| 36 | - Use schema transformers to apply customizations to OpenAPI schemas |