Instruction file imported from SantiSierraSalomo/Training202609 (
.github/instructions/dotnet-webapi.instructions.md). Copyright stays with the author.
dotnet-webapi skill
Use these guidelines when creating or modifying ASP.NET Core Web API code in this repository.
API design
- Prefer RESTful routes and clear resource naming.
- Use correct HTTP verbs (
GET,POST,PUT,PATCH,DELETE). - Return
ActionResult<T>for typed responses. - Keep controllers thin; move business logic to services.
Validation and errors
- Validate request models with data annotations and model state checks.
- Return
400 Bad Requestfor invalid input. - Return
404 Not Foundwhen entities are missing. - Return
409 Conflictfor concurrency or duplicate resource conflicts. - Use RFC7807
ProblemDetailsresponses for errors.
OpenAPI and metadata
- Ensure endpoints are discoverable in Swagger/OpenAPI.
- Add meaningful summaries and response status metadata where needed.
- Keep request/response DTOs explicit and version-safe.
Security and reliability
- Never hardcode secrets; use configuration and environment variables.
- Apply authorization attributes where endpoints require protection.
- Log failures with structured logging.
- Make async I/O operations fully asynchronous (
async/await).
Repository-specific notes
- Target framework: .NET 10.
- Main API project path:
01FirstTest\WebApplication20260818. - Keep line endings as CRLF for Windows consistency.