dotnet-webapi

Creates ASP.NET Core Web API endpoints with OpenAPI metadata and error handling.

Updated Jul 12, 2026
One-click install
npx skills add https://github.com/Patrick-Rex/DotNetTechSamples --skill dotnet-webapi-patrick-rex
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-webapi
Source: https://github.com/Patrick-Rex/DotNetTechSamples/tree/main/.agents/plugins/dotnet-aspnetcore/skills/dotnet-webapi
Command: npx skills add https://github.com/Patrick-Rex/DotNetTechSamples --skill dotnet-webapi-patrick-rex

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building ASP.NET Core Web APIs involves many conventions that are easy to get wrong: correct HTTP status codes, DTO design, OpenAPI documentation, cancellation support, and centralized error handling. This Skill guides the creation and modification of Web API endpoints so they follow consistent HTTP semantics, proper OpenAPI metadata, and RFC 7807 Problem Details error responses. ## Core Features & Use Cases - Endpoint Implementation: Adds controller-based or minimal API endpoints matching the existing project style, with correct status codes (201 with Location header, 204 for deletes) and CancellationToken forwarding. - DTO and Validation Conventions: Defines sealed record request/response types with XML doc comments, DateTimeOffset for dates, string-serialized enums, and explicit validation registration for minimal APIs. - OpenAPI and Error Handling: Wires up built-in .NET 9+ OpenAPI support (avoiding Swashbuckle on modern targets), endpoint metadata, and a global IExceptionHandler returning Problem Details. - Use Case: Ask the assistant to add a CRUD endpoint for a Product resource to an existing minimal API project, and receive the endpoint, DTOs, service layer with interface, OpenAPI metadata, exception handler, and a .http test file, verified with a clean build. ## Quick Start Add a new REST endpoint for managing products to my ASP.NET Core project, including DTOs, OpenAPI documentation, error handling, and a .http test file.

Frequently Asked Questions about dotnet-webapi

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new endpoint to an ASP.NET Core Web API?

First detect whether the project uses controllers or minimal APIs, then follow that style. Define sealed record request and response DTOs, implement the endpoint with correct status codes and CancellationToken, add OpenAPI metadata, and verify with dotnet build.

Should I use controllers or minimal APIs for a new .NET project?

For new projects, default to minimal APIs unless controllers are explicitly requested. For existing projects, match the established style and never mix controllers and minimal APIs in the same project.

Should I use Swashbuckle or built-in OpenAPI in .NET 9 and .NET 10?

Use the built-in ASP.NET Core OpenAPI support via AddOpenApi() and MapOpenApi() for .NET 9+ projects. Swashbuckle packages have known compatibility issues with .NET 9+ OpenAPI types and should only be used for .NET 8 or earlier.

Why does TypedResults cause CS1593 in minimal API handlers?

The error occurs when TypedResults.Ok and TypedResults.NotFound appear in a ternary without an explicit return type, since they share no common base type. Annotate the handler with Task<Results<Ok<T>, NotFound>> so the compiler can infer the delegate correctly.

How do I return consistent error responses from an ASP.NET Core API?

Register AddProblemDetails() and UseExceptionHandler(), then implement IExceptionHandler to map exceptions to status codes and write RFC 7807 Problem Details. Place the handler class in a Middleware folder and log exceptions before returning true.

When should this Web API guidance not be used?

Do not apply it to EF Core query optimization, frontend or Blazor work, gRPC services, or SignalR hubs. It covers only HTTP API endpoints, DTOs, OpenAPI documentation, and API error handling.