[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-dotnet-dotnet-webapi":3,"mdc--b20bt4-key":37,"related-org-dotnet-dotnet-webapi":3675,"related-repo-dotnet-dotnet-webapi":3841},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":25,"repoUrl":26,"updatedAt":27,"license":28,"forks":29,"topics":30,"repo":32,"sourceUrl":35,"mdContent":36},"dotnet-webapi","build ASP.NET Core Web APIs","Guides creation and modification of ASP.NET Core Web API endpoints with correct HTTP semantics, OpenAPI metadata, and error handling. USE FOR: adding new API endpoints (controllers or minimal APIs), wiring up OpenAPI\u002FSwagger, creating .http test files, setting up global error handling middleware. DO NOT USE FOR: general C# coding style, EF Core data access or query optimization (use optimizing-ef-core-queries), frontend\u002FBlazor work, gRPC services, or SignalR hubs.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},"dotnet",".NET (Microsoft)","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fdotnet.png",[12,16,19,22],{"name":13,"slug":14,"type":15},".NET","net","tag",{"name":17,"slug":18,"type":15},"ASP.NET Core","asp-net-core",{"name":20,"slug":21,"type":15},"API Development","api-development",{"name":23,"slug":24,"type":15},"OpenAPI","openapi",4576,"https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fskills","2026-07-12T08:23:13.851366","MIT",332,[31],"agent-skills",{"repoUrl":26,"stars":25,"forks":29,"topics":33,"description":34},[31],"Repository for skills to assist AI coding agents with .NET and C#","https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fskills\u002Ftree\u002FHEAD\u002Fplugins\u002Fdotnet-aspnetcore\u002Fskills\u002Fdotnet-webapi","---\nname: dotnet-webapi\ndescription: >\n  Guides creation and modification of ASP.NET Core Web API endpoints with\n  correct HTTP semantics, OpenAPI metadata, and error handling.\n  USE FOR: adding new API endpoints (controllers or minimal APIs), wiring up\n  OpenAPI\u002FSwagger, creating .http test files, setting up global error handling\n  middleware.\n  DO NOT USE FOR: general C# coding style, EF Core data access or query\n  optimization (use optimizing-ef-core-queries), frontend\u002FBlazor work, gRPC\n  services, or SignalR hubs.\nlicense: MIT\n---\n\n# ASP.NET Core Web API\n\nProduce well-structured ASP.NET Core Web API endpoints with proper HTTP\nsemantics, OpenAPI documentation, and error handling.\n\n## When to Use\n\nUse this skill when working on ASP.NET Core HTTP APIs, including:\n\n- adding or modifying Web API endpoints implemented with controllers or minimal APIs;\n- wiring up OpenAPI\u002FSwagger metadata and endpoint documentation;\n- defining request\u002Fresponse DTOs and consistent HTTP status code behavior;\n- adding `.http` files or similar request-based API testing artifacts;\n- configuring centralized API error handling middleware or exception mapping.\n\n## When Not to Use\n\nDo not use this skill for:\n\n- general C# coding style or non-API refactoring;\n- EF Core data modeling or query optimization work; use `optimizing-ef-core-queries`;\n- frontend, Razor, or Blazor UI changes;\n- gRPC services;\n- SignalR hubs or real-time messaging flows.\n\n## Inputs \u002F prerequisites\n\nBefore applying this skill, gather the project context needed to match the\nexisting API style and wiring:\n\n- the ASP.NET Core entry point, typically `Program.cs`;\n- any existing controllers, especially classes inheriting `ControllerBase` or\n  using `[ApiController]`;\n- any existing minimal API registrations such as `app.MapGet`, `app.MapPost`,\n  `app.MapPut`, or `app.MapDelete`;\n- related DTO, model, validation, and error-handling types already used by the project;\n- available build, run, and test commands so changes can be verified.\n\nIf the user asks for a new endpoint, inspect the current project structure first\nso the implementation follows the established conventions rather than mixing styles.\n## Workflow\n\n### Step 1: Determine the API style\n\nScan the project for existing endpoint patterns before writing any code.\n\n1. Search for classes inheriting `ControllerBase` or decorated with `[ApiController]`.\n2. Search `Program.cs` or endpoint files for `app.MapGet`, `app.MapPost`, etc.\n3. If the project already uses **controllers**, continue with controllers.\n4. If the project already uses **minimal APIs**, continue with minimal APIs.\n5. If neither exists (new project), **default to minimal APIs** unless the user\n   explicitly requests controllers.\n\nDo not mix styles in the same project.\n\n### Step 2: Define request and response types\n\nCreate dedicated types for API input and output. Never expose EF Core entities\ndirectly in request or response bodies.\n\n**Use `sealed record` for all DTOs.** Records enforce immutability, provide\nvalue-based equality, and produce concise code. Seal them to prevent unintended\ninheritance and enable JIT devirtualization (CA1852).\n\n**Naming convention:**\n\n| Role | Convention | Example |\n|------|-----------|---------|\n| Input (create) | `Create{Entity}Request` | `CreateProductRequest` |\n| Input (update) | `Update{Entity}Request` | `UpdateProductRequest` |\n| Output (single) | `{Entity}Response` | `ProductResponse` |\n| Output (list) | `{Entity}ListResponse` | `ProductListResponse` |\n\n**XML doc comments on all DTOs:** Add `\u003Csummary>` XML doc comments to every\nrequest and response type exposed in the API. These comments are automatically\nincluded in the generated OpenAPI specification, producing richer documentation\nwithout extra metadata calls.\n\nReference: https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fopenapi\u002Fopenapi-comments\n\n**Date and time values — use `DateTimeOffset`:** When a DTO includes a date or\ntime property, always use `DateTimeOffset` instead of `DateTime`.\n`DateTimeOffset` preserves the UTC offset, avoids ambiguous timezone\nconversions, and serializes to ISO 8601 with offset information in JSON — which\nis what API consumers expect.\n\nReference: https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fapi\u002Fsystem.datetimeoffset\n**JSON serialization options — preserve existing behavior by default:** For\nexisting APIs, do **not** introduce stricter serialization\u002Fdeserialization settings\nunless the project already uses them or the user explicitly asks for them. Settings\nsuch as case-sensitive property matching and strict number handling can break\nexisting clients. For **new projects**, or when strict JSON handling is explicitly\nrequested, configure options like the following to minimize the potential of\nprocessing malicious requests:\n\n```csharp\n\u002F\u002F Apply these settings only for new projects, when the existing project already\n\u002F\u002F uses them, or when the user explicitly requests stricter JSON behavior.\nbuilder.Services.ConfigureHttpJsonOptions(options =>\n{\n    \u002F\u002F disallow reading numbers from JSON strings\n    options.SerializerOptions.NumberHandling = JsonNumberHandling.Strict;\n    \u002F\u002F match properties with exact casing during deserialization\n    options.SerializerOptions.PropertyNameCaseInsensitive = false;\n    \u002F\u002F reject duplicate JSON property names during deserialization\n    options.SerializerOptions.AllowDuplicateProperties = false;\n    \u002F\u002F omit null properties from serialized output\n    options.SerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;\n});\n```\n**Enum properties — serialize as strings by default:** Unless the user\nexplicitly requests integer serialization, all enum properties should be\nserialized as strings. String-serialized enums are human-readable, less fragile\nwhen values are reordered, and produce better OpenAPI documentation. See Step 4\nfor the `JsonStringEnumConverter` configuration.\n\n**Response DTOs** — use positional sealed records for concise, immutable output:\n\n```csharp\n\u002F\u002F\u002F \u003Csummary>Represents a product returned by the API.\u003C\u002Fsummary>\npublic sealed record ProductResponse(\n    int Id,\n    string Name,\n    decimal Price,\n    Category Category,\n    bool IsAvailable,\n    DateTimeOffset CreatedAt);\n```\n\n**Request DTOs** — use sealed records with `init` properties so data annotations\nwork naturally:\n\n```csharp\n\u002F\u002F\u002F \u003Csummary>Payload for creating a new product.\u003C\u002Fsummary>\npublic sealed record CreateProductRequest\n{\n    [Required, MaxLength(200)]\n    public required string Name { get; init; }\n\n    [Range(0.01, 999999.99)]\n    public required decimal Price { get; init; }\n\n    public required Category Category { get; init; }\n}\n```\n\nFollow the same pattern for `Update{Entity}Request` records, adding any\nadditional properties the update requires (e.g., `IsAvailable`).\n\n**Minimal API validation — register explicitly:** Data-annotation validation\n(`[Required]`, `[MaxLength]`, `[Range]`, etc.) is automatic in MVC controllers,\nbut minimal APIs require explicit opt-in. For **.NET 10+** projects using minimal\nAPIs, add the validation services in `Program.cs`:\n\n```csharp\nbuilder.Services.AddValidation();\n```\n\nThis wires up an endpoint filter that validates parameters decorated with data\nannotations before the handler executes, returning a `400 Bad Request` with a\nvalidation problem details response on failure.\n\nReference: https:\u002F\u002Flearn.microsoft.com\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fminimal-apis?view=aspnetcore-10.0\n\n**Do not** use mutable classes (`{ get; set; }`) for DTOs. Mutable DTOs allow\naccidental modification after construction and lose the self-documenting\nimmutability that records provide.\n\n### Step 3: Implement the endpoints\n\nWhether using controllers or minimal APIs, follow these HTTP conventions\nconsistently.\n\n**Organizing minimal API endpoints:** For projects using minimal APIs, organize\nendpoints by resource using static classes with a static `Map\u003CResource>` method.\nThis pattern keeps endpoint definitions grouped by resource type, making the\ncode more maintainable and easier to navigate as the API grows.\n\n**Pattern structure:**\n\n1. Create one static class per resource (e.g., `ProductEndpoints`, `CategoryEndpoints`).\n2. Define a static `Map\u003CResource>(this WebApplication app)` extension method.\n3. Inside the method, call `MapGet`, `MapPost`, `MapPut`, `MapDelete`, etc. for\n   that resource's endpoints.\n4. In `Program.cs`, call each resource's `Map` method in order.\n\n**Minimal API return types — prefer `TypedResults`:**\n\nAlways prefer `TypedResults` over the `Results` factory. `TypedResults` embeds\nresponse type information in the method signature, giving the OpenAPI generator\nricher metadata automatically.\n\nWhen a handler returns **multiple result types** (e.g., `Ok` or `NotFound`),\nannotate the lambda with an explicit `Results\u003CT1, T2>` return type. This\nlets you use `TypedResults` while still giving the compiler a common type:\n\n```csharp\nasync Task\u003CResults\u003COk\u003CProductResponse>, NotFound>> (int id, ...) => ...\n```\n\n**Do not** use `TypedResults.Ok(x)` and `TypedResults.NotFound()` in a bare\nternary without an explicit return type annotation. `Ok\u003CT>` and `NotFound` are\ndifferent types with no common base the compiler can infer, which causes\n`CS1593: Delegate 'RequestDelegate' does not take N arguments` because the\ncompiler falls back to matching `RequestDelegate(HttpContext)`.\n\n**Fallback — `Results` factory:** If a handler has many conditional branches\n(7+ result types), you may use the `Results` factory (`Results.Ok()`,\n`Results.NotFound()`) which returns `IResult`, sacrificing compile-time OpenAPI\ninference for simpler signatures.\n\n**Status codes:**\n\n| Operation | Success | Common errors |\n|-----------|---------|---------------|\n| GET (single) | `200 OK` | `404 Not Found` |\n| GET (list) | `200 OK` | — |\n| POST (create) | `201 Created` with `Location` header | `400 Bad Request`, `409 Conflict` |\n| PUT (full update) | `200 OK` | `400 Bad Request`, `404 Not Found` |\n| PATCH (partial\u002Faction) | `200 OK` | `400 Bad Request`, `404 Not Found` |\n| DELETE | `204 No Content` | `404 Not Found`, `409 Conflict` |\n\n**POST 201 responses:** Always return a `Location` header pointing to the\nnewly created resource.\n\n- Controllers: use `CreatedAtAction(nameof(GetById), new { id = ... }, response)`\n- Minimal APIs: use `TypedResults.Created($\"\u002Fapi\u002Fproducts\u002F{id}\", response)`\n\n**CancellationToken:** Accept `CancellationToken` in every endpoint signature\nand forward it through to all async calls (service methods, EF Core queries,\n`HttpClient` calls). This allows the server to stop work when a client\ndisconnects.\n\n```csharp\n\u002F\u002F Controller example\n[HttpGet(\"{id}\")]\npublic async Task\u003CActionResult\u003CProductResponse>> GetById(\n    int id, CancellationToken cancellationToken)\n{\n    var product = await _productService.GetByIdAsync(id, cancellationToken);\n    return product is null ? NotFound() : Ok(product);\n}\n\n\u002F\u002F Minimal API example — TypedResults with explicit return type (recommended)\napp.MapGet(\"\u002Fapi\u002Fproducts\u002F{id}\", async Task\u003CResults\u003COk\u003CProductResponse>, NotFound>> (\n    int id, IProductService service, CancellationToken cancellationToken) =>\n{\n    var product = await service.GetByIdAsync(id, cancellationToken);\n    return product is null ? TypedResults.NotFound() : TypedResults.Ok(product);\n});\n```\n\n### Step 4: Wire up OpenAPI\n\nEvery ASP.NET Core Web API should have OpenAPI documentation. Check whether\nthe project already has OpenAPI configured before adding it.\n\n**For .NET 9+ projects**, use the built-in ASP.NET Core OpenAPI support\n(`builder.Services.AddOpenApi()` + `app.MapOpenApi()` in development).\nThis is all that is needed — no additional packages required.\n\n**Do NOT add any `Swashbuckle.*` NuGet package** (`Swashbuckle.AspNetCore`,\n`Swashbuckle.AspNetCore.SwaggerUI`, `Swashbuckle.AspNetCore.SwaggerGen`,\netc.) to .NET 9+ projects. Swashbuckle has known compatibility issues with\n.NET 9+ and .NET 10 OpenAPI types. For projects targeting .NET 8 or earlier,\nSwashbuckle is acceptable. If the project already has Swashbuckle installed,\nkeep it unless the user asks to remove it.\n\nReference: https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fopenapi\u002Foverview\n\n**OpenAPI metadata on endpoints:** Add descriptive metadata so the generated\ndocumentation is useful, not just a list of routes. For minimal APIs, chain\nthe metadata methods:\n\n```csharp\napp.MapGet(\"\u002Fapi\u002Fproducts\u002F{id}\", handler)\n    .WithName(\"GetProductById\")\n    .WithSummary(\"Get a product by ID\")\n    .WithDescription(\"Returns the full product details including category.\")\n    .Produces\u003CProductResponse>(StatusCodes.Status200OK)\n    .Produces(StatusCodes.Status404NotFound);\n```\n\n**Enum serialization (strings by default):** Configure JSON serialization so\nenums appear as readable strings in both API responses and OpenAPI schemas.\nAlways add this configuration unless the user explicitly requests integer\nenum serialization. Configure it for both minimal APIs and controllers, as\nthey use different option types:\n\n```csharp\n\u002F\u002F Minimal APIs\nbuilder.Services.ConfigureHttpJsonOptions(options =>\n    options.SerializerOptions.Converters.Add(new JsonStringEnumConverter()));\n\n\u002F\u002F Controllers \u002F MVC\nbuilder.Services.AddControllers()\n    .AddJsonOptions(options =>\n    {\n        options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());\n    });\n```\n\n### Step 5: Set up error handling\n\nUse a global exception handler so that individual endpoints do not need\ntry-catch blocks. Return RFC 7807 Problem Details for all error responses.\n\n**For .NET 8+ projects**, prefer the built-in exception handler middleware:\n\n```csharp\nbuilder.Services.AddProblemDetails();\n\napp.UseExceptionHandler();\napp.UseStatusCodePages();\n```\n\nIf the project needs custom exception-to-status-code mapping (e.g., a\n`NotFoundException` should return 404), implement `IExceptionHandler`:\n\n```csharp\ninternal sealed class ApiExceptionHandler(ILogger\u003CApiExceptionHandler> logger)\n    : IExceptionHandler\n{\n    public async ValueTask\u003Cbool> TryHandleAsync(\n        HttpContext httpContext,\n        Exception exception,\n        CancellationToken cancellationToken)\n    {\n        var (statusCode, title) = exception switch\n        {\n            KeyNotFoundException => (StatusCodes.Status404NotFound, \"Not Found\"),\n            ArgumentException => (StatusCodes.Status400BadRequest, \"Bad Request\"),\n            InvalidOperationException => (StatusCodes.Status409Conflict, \"Conflict\"),\n            _ => (0, (string?)null)\n        };\n\n        if (statusCode == 0)\n            return false; \u002F\u002F Let the default handler deal with it\n\n        \u002F\u002F Important: returning true below suppresses the exception diagnostics middleware\n        \u002F\u002F for this exception, so ensure it is logged\u002Ftelemetrized before returning.\n        logger.LogWarning(exception, \"Handled API exception: {Title}\", title);\n\n        httpContext.Response.StatusCode = statusCode;\n        await httpContext.Response.WriteAsJsonAsync(new ProblemDetails\n        {\n            Status = statusCode,\n            Title = title,\n            \u002F\u002F Do not use exception.Message here — it may leak sensitive internal details.\n            \u002F\u002F Use a safe, user-facing message instead.\n            Detail = title,\n            Instance = httpContext.Request.Path\n        }, cancellationToken);\n\n        return true;\n    }\n}\n```\n\nRegister it:\n\n```csharp\nbuilder.Services.AddExceptionHandler\u003CApiExceptionHandler>();\nbuilder.Services.AddProblemDetails();\n\napp.UseExceptionHandler();\n```\n\n**File placement:** Always place exception handler classes in a `Middleware\u002F`\nfolder to maintain consistent project organization. Do not place them at the\nproject root.\n\n### Step 6: Use a service layer\n\nDo not inject data stores directly into controllers or endpoint handlers.\nCreate a service interface and a sealed implementation class that owns the\ndata access logic and mapping between entities and request\u002Fresponse types.\n\nAlways define an interface for every service — this enables unit testing with\nmocks and follows the Dependency Inversion Principle:\n\n```csharp\n\u002F\u002F Services\u002FIProductService.cs\npublic interface IProductService\n{\n    Task\u003CIReadOnlyList\u003CProductResponse>> GetAllAsync(CancellationToken ct);\n    Task\u003CProductResponse?> GetByIdAsync(int id, CancellationToken ct);\n    Task\u003CProductResponse> CreateAsync(CreateProductRequest request, CancellationToken ct);\n}\n\n\u002F\u002F Services\u002FProductService.cs\npublic sealed class ProductService(...) : IProductService\n{\n    \u002F\u002F Data access logic, entity-to-DTO mapping\n}\n```\n\nRegister with the interface, not the concrete type:\n\n```csharp\n\u002F\u002F In Program.cs\nbuilder.Services.AddScoped\u003CIProductService, ProductService>();\n```\n\nFor EF Core data access patterns (migrations, Fluent API configuration,\n`AsNoTracking`, seed data), see the `optimizing-ef-core-queries` skill.\n\n### Step 7: Create a .http test file\n\nAfter implementing endpoints, create a `.http` file in the project root that\ndemonstrates how to call every new endpoint. This serves as living\ndocumentation and a quick manual test harness.\n\n```http\n@baseUrl = http:\u002F\u002Flocalhost:5000\n\n### Get all products\nGET {{baseUrl}}\u002Fapi\u002Fproducts\n\n### Get product by ID\nGET {{baseUrl}}\u002Fapi\u002Fproducts\u002F1\n\n### Create a product\nPOST {{baseUrl}}\u002Fapi\u002Fproducts\nContent-Type: application\u002Fjson\n\n{\n  \"name\": \"Wireless Mouse\",\n  \"price\": 29.99,\n  \"category\": \"Electronics\"\n}\n\n### Delete a product\nDELETE {{baseUrl}}\u002Fapi\u002Fproducts\u002F1\n```\n\nInclude at least one request per endpoint with realistic bodies. Show error\npaths (e.g., non-existent IDs). Match the port to `launchSettings.json`.\n\n### Step 8: Build and verify\n\n1. Run `dotnet build` — confirm zero errors and zero warnings.\n2. Start the app and verify the OpenAPI document loads (default: `\u002Fopenapi\u002Fv1.json`).\n3. Run the requests in the `.http` file and confirm correct status codes.\n\n## Validation\n\n- [ ] All endpoints return correct HTTP status codes per the table in Step 3\n- [ ] POST endpoints return `201 Created` with a `Location` header\n- [ ] DELETE endpoints return `204 No Content`\n- [ ] Every endpoint signature includes `CancellationToken`\n- [ ] `CancellationToken` is forwarded to all downstream async calls\n- [ ] OpenAPI document is generated and includes all new endpoints\n- [ ] Endpoints have summary\u002Fdescription metadata for OpenAPI\n- [ ] Enum values appear as strings in JSON responses and OpenAPI schemas (unless user explicitly requested integer serialization)\n- [ ] Error responses use RFC 7807 Problem Details format\n- [ ] Domain entities are not exposed directly in API request\u002Fresponse bodies\n- [ ] All API-exposed DTOs have `\u003Csummary>` XML doc comments\n- [ ] Date and time properties use `DateTimeOffset`, not `DateTime`\n- [ ] A `.http` file exists with a request for every new endpoint\n- [ ] `dotnet build` passes with zero errors and zero warnings\n- [ ] All DTOs are `sealed record` types (not mutable classes)\n- [ ] Minimal API handlers use `TypedResults` with explicit `Results\u003CT1, T2>` return types\n- [ ] Every service has a corresponding interface registered in DI\n- [ ] Exception handlers are placed in the `Middleware\u002F` folder\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| Exposing domain entities as API responses | Create separate `sealed record` request\u002Fresponse types. Entities leak navigation properties and internal fields. |\n| Forgetting `CancellationToken` | Add to every endpoint and forward through the entire async call chain. |\n| Returning `200 OK` from POST create | Return `201 Created` with a `Location` header. |\n| Missing OpenAPI metadata | Chain `.WithName()`, `.WithSummary()`, `.WithDescription()`, `.Produces\u003CT>()` on every endpoint. |\n| Injecting data stores directly into endpoints | Use a service layer with an interface for separation and testability. |\n| Mixing controller and minimal API styles | Pick one per project and be consistent. |\n| `TypedResults` in ternary without explicit return type | `Ok\u003CT>` and `NotFound` have no common base — annotate with `Task\u003CResults\u003COk\u003CT>, NotFound>>` or fall back to `Results` factory. |\n| Using mutable classes for DTOs | Use `sealed record` with positional syntax (responses) or `init` properties (requests). |\n| Registering services without interfaces | Define `IService` and register with `AddScoped\u003CIService, Service>()`. |\n| Adding any `Swashbuckle.*` package to new .NET 9+ projects | Use built-in `AddOpenApi()` + `MapOpenApi()`. Do not add `Swashbuckle.AspNetCore`, `Swashbuckle.AspNetCore.SwaggerUI`, or any other Swashbuckle package. |\n| Missing XML doc comments on DTOs | Add `\u003Csummary>` XML doc comments to every request and response type. These flow into the generated OpenAPI spec automatically. |\n| Using `DateTime` for date\u002Ftime properties | Use `DateTimeOffset` instead — it preserves UTC offset, avoids timezone ambiguity, and serializes correctly in JSON. |\n| Serializing enums as integers | Configure `JsonStringEnumConverter` so enums serialize as strings by default. Only use integer serialization if the user explicitly requests it. |\n\n## More Info\n\n- [ASP.NET Core Web API overview](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Fweb-api\u002F) — fundamental concepts for building Web APIs\n- [OpenAPI in ASP.NET Core](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fopenapi\u002Foverview) — built-in OpenAPI support in .NET 9+\n- [OpenAPI from XML comments](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fopenapi\u002Fopenapi-comments) — how XML doc comments flow into the OpenAPI spec\n- [Minimal APIs overview](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fminimal-apis\u002Foverview) — routing, parameter binding, and response types\n- [Handle errors in ASP.NET Core APIs](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Fweb-api\u002Fhandle-errors) — Problem Details and exception handling\n- [DateTimeOffset](https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fapi\u002Fsystem.datetimeoffset) — preferred type for date\u002Ftime values in APIs\n",{"data":38,"body":39},{"name":4,"description":6,"license":28},{"type":40,"children":41},"root",[42,51,57,64,69,108,114,119,155,161,166,247,252,258,265,270,354,359,365,370,388,396,533,551,564,604,635,765,783,793,864,882,976,996,1041,1055,1068,1078,1096,1102,1107,1125,1133,1222,1237,1264,1307,1321,1375,1422,1430,1637,1654,1679,1705,1838,1844,1849,1875,1915,1925,1935,1990,2000,2085,2091,2096,2106,2144,2164,2480,2485,2521,2539,2545,2550,2555,2661,2666,2689,2709,2715,2727,2889,2901,2907,2947,2953,3213,3219,3592,3598,3669],{"type":43,"tag":44,"props":45,"children":47},"element","h1",{"id":46},"aspnet-core-web-api",[48],{"type":49,"value":50},"text","ASP.NET Core Web API",{"type":43,"tag":52,"props":53,"children":54},"p",{},[55],{"type":49,"value":56},"Produce well-structured ASP.NET Core Web API endpoints with proper HTTP\nsemantics, OpenAPI documentation, and error handling.",{"type":43,"tag":58,"props":59,"children":61},"h2",{"id":60},"when-to-use",[62],{"type":49,"value":63},"When to Use",{"type":43,"tag":52,"props":65,"children":66},{},[67],{"type":49,"value":68},"Use this skill when working on ASP.NET Core HTTP APIs, including:",{"type":43,"tag":70,"props":71,"children":72},"ul",{},[73,79,84,89,103],{"type":43,"tag":74,"props":75,"children":76},"li",{},[77],{"type":49,"value":78},"adding or modifying Web API endpoints implemented with controllers or minimal APIs;",{"type":43,"tag":74,"props":80,"children":81},{},[82],{"type":49,"value":83},"wiring up OpenAPI\u002FSwagger metadata and endpoint documentation;",{"type":43,"tag":74,"props":85,"children":86},{},[87],{"type":49,"value":88},"defining request\u002Fresponse DTOs and consistent HTTP status code behavior;",{"type":43,"tag":74,"props":90,"children":91},{},[92,94,101],{"type":49,"value":93},"adding ",{"type":43,"tag":95,"props":96,"children":98},"code",{"className":97},[],[99],{"type":49,"value":100},".http",{"type":49,"value":102}," files or similar request-based API testing artifacts;",{"type":43,"tag":74,"props":104,"children":105},{},[106],{"type":49,"value":107},"configuring centralized API error handling middleware or exception mapping.",{"type":43,"tag":58,"props":109,"children":111},{"id":110},"when-not-to-use",[112],{"type":49,"value":113},"When Not to Use",{"type":43,"tag":52,"props":115,"children":116},{},[117],{"type":49,"value":118},"Do not use this skill for:",{"type":43,"tag":70,"props":120,"children":121},{},[122,127,140,145,150],{"type":43,"tag":74,"props":123,"children":124},{},[125],{"type":49,"value":126},"general C# coding style or non-API refactoring;",{"type":43,"tag":74,"props":128,"children":129},{},[130,132,138],{"type":49,"value":131},"EF Core data modeling or query optimization work; use ",{"type":43,"tag":95,"props":133,"children":135},{"className":134},[],[136],{"type":49,"value":137},"optimizing-ef-core-queries",{"type":49,"value":139},";",{"type":43,"tag":74,"props":141,"children":142},{},[143],{"type":49,"value":144},"frontend, Razor, or Blazor UI changes;",{"type":43,"tag":74,"props":146,"children":147},{},[148],{"type":49,"value":149},"gRPC services;",{"type":43,"tag":74,"props":151,"children":152},{},[153],{"type":49,"value":154},"SignalR hubs or real-time messaging flows.",{"type":43,"tag":58,"props":156,"children":158},{"id":157},"inputs-prerequisites",[159],{"type":49,"value":160},"Inputs \u002F prerequisites",{"type":43,"tag":52,"props":162,"children":163},{},[164],{"type":49,"value":165},"Before applying this skill, gather the project context needed to match the\nexisting API style and wiring:",{"type":43,"tag":70,"props":167,"children":168},{},[169,181,201,237,242],{"type":43,"tag":74,"props":170,"children":171},{},[172,174,180],{"type":49,"value":173},"the ASP.NET Core entry point, typically ",{"type":43,"tag":95,"props":175,"children":177},{"className":176},[],[178],{"type":49,"value":179},"Program.cs",{"type":49,"value":139},{"type":43,"tag":74,"props":182,"children":183},{},[184,186,192,194,200],{"type":49,"value":185},"any existing controllers, especially classes inheriting ",{"type":43,"tag":95,"props":187,"children":189},{"className":188},[],[190],{"type":49,"value":191},"ControllerBase",{"type":49,"value":193}," or\nusing ",{"type":43,"tag":95,"props":195,"children":197},{"className":196},[],[198],{"type":49,"value":199},"[ApiController]",{"type":49,"value":139},{"type":43,"tag":74,"props":202,"children":203},{},[204,206,212,214,220,222,228,230,236],{"type":49,"value":205},"any existing minimal API registrations such as ",{"type":43,"tag":95,"props":207,"children":209},{"className":208},[],[210],{"type":49,"value":211},"app.MapGet",{"type":49,"value":213},", ",{"type":43,"tag":95,"props":215,"children":217},{"className":216},[],[218],{"type":49,"value":219},"app.MapPost",{"type":49,"value":221},",\n",{"type":43,"tag":95,"props":223,"children":225},{"className":224},[],[226],{"type":49,"value":227},"app.MapPut",{"type":49,"value":229},", or ",{"type":43,"tag":95,"props":231,"children":233},{"className":232},[],[234],{"type":49,"value":235},"app.MapDelete",{"type":49,"value":139},{"type":43,"tag":74,"props":238,"children":239},{},[240],{"type":49,"value":241},"related DTO, model, validation, and error-handling types already used by the project;",{"type":43,"tag":74,"props":243,"children":244},{},[245],{"type":49,"value":246},"available build, run, and test commands so changes can be verified.",{"type":43,"tag":52,"props":248,"children":249},{},[250],{"type":49,"value":251},"If the user asks for a new endpoint, inspect the current project structure first\nso the implementation follows the established conventions rather than mixing styles.",{"type":43,"tag":58,"props":253,"children":255},{"id":254},"workflow",[256],{"type":49,"value":257},"Workflow",{"type":43,"tag":259,"props":260,"children":262},"h3",{"id":261},"step-1-determine-the-api-style",[263],{"type":49,"value":264},"Step 1: Determine the API style",{"type":43,"tag":52,"props":266,"children":267},{},[268],{"type":49,"value":269},"Scan the project for existing endpoint patterns before writing any code.",{"type":43,"tag":271,"props":272,"children":273},"ol",{},[274,293,318,331,342],{"type":43,"tag":74,"props":275,"children":276},{},[277,279,284,286,291],{"type":49,"value":278},"Search for classes inheriting ",{"type":43,"tag":95,"props":280,"children":282},{"className":281},[],[283],{"type":49,"value":191},{"type":49,"value":285}," or decorated with ",{"type":43,"tag":95,"props":287,"children":289},{"className":288},[],[290],{"type":49,"value":199},{"type":49,"value":292},".",{"type":43,"tag":74,"props":294,"children":295},{},[296,298,303,305,310,311,316],{"type":49,"value":297},"Search ",{"type":43,"tag":95,"props":299,"children":301},{"className":300},[],[302],{"type":49,"value":179},{"type":49,"value":304}," or endpoint files for ",{"type":43,"tag":95,"props":306,"children":308},{"className":307},[],[309],{"type":49,"value":211},{"type":49,"value":213},{"type":43,"tag":95,"props":312,"children":314},{"className":313},[],[315],{"type":49,"value":219},{"type":49,"value":317},", etc.",{"type":43,"tag":74,"props":319,"children":320},{},[321,323,329],{"type":49,"value":322},"If the project already uses ",{"type":43,"tag":324,"props":325,"children":326},"strong",{},[327],{"type":49,"value":328},"controllers",{"type":49,"value":330},", continue with controllers.",{"type":43,"tag":74,"props":332,"children":333},{},[334,335,340],{"type":49,"value":322},{"type":43,"tag":324,"props":336,"children":337},{},[338],{"type":49,"value":339},"minimal APIs",{"type":49,"value":341},", continue with minimal APIs.",{"type":43,"tag":74,"props":343,"children":344},{},[345,347,352],{"type":49,"value":346},"If neither exists (new project), ",{"type":43,"tag":324,"props":348,"children":349},{},[350],{"type":49,"value":351},"default to minimal APIs",{"type":49,"value":353}," unless the user\nexplicitly requests controllers.",{"type":43,"tag":52,"props":355,"children":356},{},[357],{"type":49,"value":358},"Do not mix styles in the same project.",{"type":43,"tag":259,"props":360,"children":362},{"id":361},"step-2-define-request-and-response-types",[363],{"type":49,"value":364},"Step 2: Define request and response types",{"type":43,"tag":52,"props":366,"children":367},{},[368],{"type":49,"value":369},"Create dedicated types for API input and output. Never expose EF Core entities\ndirectly in request or response bodies.",{"type":43,"tag":52,"props":371,"children":372},{},[373,386],{"type":43,"tag":324,"props":374,"children":375},{},[376,378,384],{"type":49,"value":377},"Use ",{"type":43,"tag":95,"props":379,"children":381},{"className":380},[],[382],{"type":49,"value":383},"sealed record",{"type":49,"value":385}," for all DTOs.",{"type":49,"value":387}," Records enforce immutability, provide\nvalue-based equality, and produce concise code. Seal them to prevent unintended\ninheritance and enable JIT devirtualization (CA1852).",{"type":43,"tag":52,"props":389,"children":390},{},[391],{"type":43,"tag":324,"props":392,"children":393},{},[394],{"type":49,"value":395},"Naming convention:",{"type":43,"tag":397,"props":398,"children":399},"table",{},[400,424],{"type":43,"tag":401,"props":402,"children":403},"thead",{},[404],{"type":43,"tag":405,"props":406,"children":407},"tr",{},[408,414,419],{"type":43,"tag":409,"props":410,"children":411},"th",{},[412],{"type":49,"value":413},"Role",{"type":43,"tag":409,"props":415,"children":416},{},[417],{"type":49,"value":418},"Convention",{"type":43,"tag":409,"props":420,"children":421},{},[422],{"type":49,"value":423},"Example",{"type":43,"tag":425,"props":426,"children":427},"tbody",{},[428,455,481,507],{"type":43,"tag":405,"props":429,"children":430},{},[431,437,446],{"type":43,"tag":432,"props":433,"children":434},"td",{},[435],{"type":49,"value":436},"Input (create)",{"type":43,"tag":432,"props":438,"children":439},{},[440],{"type":43,"tag":95,"props":441,"children":443},{"className":442},[],[444],{"type":49,"value":445},"Create{Entity}Request",{"type":43,"tag":432,"props":447,"children":448},{},[449],{"type":43,"tag":95,"props":450,"children":452},{"className":451},[],[453],{"type":49,"value":454},"CreateProductRequest",{"type":43,"tag":405,"props":456,"children":457},{},[458,463,472],{"type":43,"tag":432,"props":459,"children":460},{},[461],{"type":49,"value":462},"Input (update)",{"type":43,"tag":432,"props":464,"children":465},{},[466],{"type":43,"tag":95,"props":467,"children":469},{"className":468},[],[470],{"type":49,"value":471},"Update{Entity}Request",{"type":43,"tag":432,"props":473,"children":474},{},[475],{"type":43,"tag":95,"props":476,"children":478},{"className":477},[],[479],{"type":49,"value":480},"UpdateProductRequest",{"type":43,"tag":405,"props":482,"children":483},{},[484,489,498],{"type":43,"tag":432,"props":485,"children":486},{},[487],{"type":49,"value":488},"Output (single)",{"type":43,"tag":432,"props":490,"children":491},{},[492],{"type":43,"tag":95,"props":493,"children":495},{"className":494},[],[496],{"type":49,"value":497},"{Entity}Response",{"type":43,"tag":432,"props":499,"children":500},{},[501],{"type":43,"tag":95,"props":502,"children":504},{"className":503},[],[505],{"type":49,"value":506},"ProductResponse",{"type":43,"tag":405,"props":508,"children":509},{},[510,515,524],{"type":43,"tag":432,"props":511,"children":512},{},[513],{"type":49,"value":514},"Output (list)",{"type":43,"tag":432,"props":516,"children":517},{},[518],{"type":43,"tag":95,"props":519,"children":521},{"className":520},[],[522],{"type":49,"value":523},"{Entity}ListResponse",{"type":43,"tag":432,"props":525,"children":526},{},[527],{"type":43,"tag":95,"props":528,"children":530},{"className":529},[],[531],{"type":49,"value":532},"ProductListResponse",{"type":43,"tag":52,"props":534,"children":535},{},[536,541,543,549],{"type":43,"tag":324,"props":537,"children":538},{},[539],{"type":49,"value":540},"XML doc comments on all DTOs:",{"type":49,"value":542}," Add ",{"type":43,"tag":95,"props":544,"children":546},{"className":545},[],[547],{"type":49,"value":548},"\u003Csummary>",{"type":49,"value":550}," XML doc comments to every\nrequest and response type exposed in the API. These comments are automatically\nincluded in the generated OpenAPI specification, producing richer documentation\nwithout extra metadata calls.",{"type":43,"tag":52,"props":552,"children":553},{},[554,556],{"type":49,"value":555},"Reference: ",{"type":43,"tag":557,"props":558,"children":562},"a",{"href":559,"rel":560},"https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fopenapi\u002Fopenapi-comments",[561],"nofollow",[563],{"type":49,"value":559},{"type":43,"tag":52,"props":565,"children":566},{},[567,580,582,587,589,595,597,602],{"type":43,"tag":324,"props":568,"children":569},{},[570,572,578],{"type":49,"value":571},"Date and time values — use ",{"type":43,"tag":95,"props":573,"children":575},{"className":574},[],[576],{"type":49,"value":577},"DateTimeOffset",{"type":49,"value":579},":",{"type":49,"value":581}," When a DTO includes a date or\ntime property, always use ",{"type":43,"tag":95,"props":583,"children":585},{"className":584},[],[586],{"type":49,"value":577},{"type":49,"value":588}," instead of ",{"type":43,"tag":95,"props":590,"children":592},{"className":591},[],[593],{"type":49,"value":594},"DateTime",{"type":49,"value":596},".\n",{"type":43,"tag":95,"props":598,"children":600},{"className":599},[],[601],{"type":49,"value":577},{"type":49,"value":603}," preserves the UTC offset, avoids ambiguous timezone\nconversions, and serializes to ISO 8601 with offset information in JSON — which\nis what API consumers expect.",{"type":43,"tag":52,"props":605,"children":606},{},[607,608,614,619,621,626,628,633],{"type":49,"value":555},{"type":43,"tag":557,"props":609,"children":612},{"href":610,"rel":611},"https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fapi\u002Fsystem.datetimeoffset",[561],[613],{"type":49,"value":610},{"type":43,"tag":324,"props":615,"children":616},{},[617],{"type":49,"value":618},"JSON serialization options — preserve existing behavior by default:",{"type":49,"value":620}," For\nexisting APIs, do ",{"type":43,"tag":324,"props":622,"children":623},{},[624],{"type":49,"value":625},"not",{"type":49,"value":627}," introduce stricter serialization\u002Fdeserialization settings\nunless the project already uses them or the user explicitly asks for them. Settings\nsuch as case-sensitive property matching and strict number handling can break\nexisting clients. For ",{"type":43,"tag":324,"props":629,"children":630},{},[631],{"type":49,"value":632},"new projects",{"type":49,"value":634},", or when strict JSON handling is explicitly\nrequested, configure options like the following to minimize the potential of\nprocessing malicious requests:",{"type":43,"tag":636,"props":637,"children":642},"pre",{"className":638,"code":639,"language":640,"meta":641,"style":641},"language-csharp shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F Apply these settings only for new projects, when the existing project already\n\u002F\u002F uses them, or when the user explicitly requests stricter JSON behavior.\nbuilder.Services.ConfigureHttpJsonOptions(options =>\n{\n    \u002F\u002F disallow reading numbers from JSON strings\n    options.SerializerOptions.NumberHandling = JsonNumberHandling.Strict;\n    \u002F\u002F match properties with exact casing during deserialization\n    options.SerializerOptions.PropertyNameCaseInsensitive = false;\n    \u002F\u002F reject duplicate JSON property names during deserialization\n    options.SerializerOptions.AllowDuplicateProperties = false;\n    \u002F\u002F omit null properties from serialized output\n    options.SerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;\n});\n","csharp","",[643],{"type":43,"tag":95,"props":644,"children":645},{"__ignoreMap":641},[646,657,666,675,684,693,702,711,720,729,738,747,756],{"type":43,"tag":647,"props":648,"children":651},"span",{"class":649,"line":650},"line",1,[652],{"type":43,"tag":647,"props":653,"children":654},{},[655],{"type":49,"value":656},"\u002F\u002F Apply these settings only for new projects, when the existing project already\n",{"type":43,"tag":647,"props":658,"children":660},{"class":649,"line":659},2,[661],{"type":43,"tag":647,"props":662,"children":663},{},[664],{"type":49,"value":665},"\u002F\u002F uses them, or when the user explicitly requests stricter JSON behavior.\n",{"type":43,"tag":647,"props":667,"children":669},{"class":649,"line":668},3,[670],{"type":43,"tag":647,"props":671,"children":672},{},[673],{"type":49,"value":674},"builder.Services.ConfigureHttpJsonOptions(options =>\n",{"type":43,"tag":647,"props":676,"children":678},{"class":649,"line":677},4,[679],{"type":43,"tag":647,"props":680,"children":681},{},[682],{"type":49,"value":683},"{\n",{"type":43,"tag":647,"props":685,"children":687},{"class":649,"line":686},5,[688],{"type":43,"tag":647,"props":689,"children":690},{},[691],{"type":49,"value":692},"    \u002F\u002F disallow reading numbers from JSON strings\n",{"type":43,"tag":647,"props":694,"children":696},{"class":649,"line":695},6,[697],{"type":43,"tag":647,"props":698,"children":699},{},[700],{"type":49,"value":701},"    options.SerializerOptions.NumberHandling = JsonNumberHandling.Strict;\n",{"type":43,"tag":647,"props":703,"children":705},{"class":649,"line":704},7,[706],{"type":43,"tag":647,"props":707,"children":708},{},[709],{"type":49,"value":710},"    \u002F\u002F match properties with exact casing during deserialization\n",{"type":43,"tag":647,"props":712,"children":714},{"class":649,"line":713},8,[715],{"type":43,"tag":647,"props":716,"children":717},{},[718],{"type":49,"value":719},"    options.SerializerOptions.PropertyNameCaseInsensitive = false;\n",{"type":43,"tag":647,"props":721,"children":723},{"class":649,"line":722},9,[724],{"type":43,"tag":647,"props":725,"children":726},{},[727],{"type":49,"value":728},"    \u002F\u002F reject duplicate JSON property names during deserialization\n",{"type":43,"tag":647,"props":730,"children":732},{"class":649,"line":731},10,[733],{"type":43,"tag":647,"props":734,"children":735},{},[736],{"type":49,"value":737},"    options.SerializerOptions.AllowDuplicateProperties = false;\n",{"type":43,"tag":647,"props":739,"children":741},{"class":649,"line":740},11,[742],{"type":43,"tag":647,"props":743,"children":744},{},[745],{"type":49,"value":746},"    \u002F\u002F omit null properties from serialized output\n",{"type":43,"tag":647,"props":748,"children":750},{"class":649,"line":749},12,[751],{"type":43,"tag":647,"props":752,"children":753},{},[754],{"type":49,"value":755},"    options.SerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;\n",{"type":43,"tag":647,"props":757,"children":759},{"class":649,"line":758},13,[760],{"type":43,"tag":647,"props":761,"children":762},{},[763],{"type":49,"value":764},"});\n",{"type":43,"tag":52,"props":766,"children":767},{},[768,773,775,781],{"type":43,"tag":324,"props":769,"children":770},{},[771],{"type":49,"value":772},"Enum properties — serialize as strings by default:",{"type":49,"value":774}," Unless the user\nexplicitly requests integer serialization, all enum properties should be\nserialized as strings. String-serialized enums are human-readable, less fragile\nwhen values are reordered, and produce better OpenAPI documentation. See Step 4\nfor the ",{"type":43,"tag":95,"props":776,"children":778},{"className":777},[],[779],{"type":49,"value":780},"JsonStringEnumConverter",{"type":49,"value":782}," configuration.",{"type":43,"tag":52,"props":784,"children":785},{},[786,791],{"type":43,"tag":324,"props":787,"children":788},{},[789],{"type":49,"value":790},"Response DTOs",{"type":49,"value":792}," — use positional sealed records for concise, immutable output:",{"type":43,"tag":636,"props":794,"children":796},{"className":638,"code":795,"language":640,"meta":641,"style":641},"\u002F\u002F\u002F \u003Csummary>Represents a product returned by the API.\u003C\u002Fsummary>\npublic sealed record ProductResponse(\n    int Id,\n    string Name,\n    decimal Price,\n    Category Category,\n    bool IsAvailable,\n    DateTimeOffset CreatedAt);\n",[797],{"type":43,"tag":95,"props":798,"children":799},{"__ignoreMap":641},[800,808,816,824,832,840,848,856],{"type":43,"tag":647,"props":801,"children":802},{"class":649,"line":650},[803],{"type":43,"tag":647,"props":804,"children":805},{},[806],{"type":49,"value":807},"\u002F\u002F\u002F \u003Csummary>Represents a product returned by the API.\u003C\u002Fsummary>\n",{"type":43,"tag":647,"props":809,"children":810},{"class":649,"line":659},[811],{"type":43,"tag":647,"props":812,"children":813},{},[814],{"type":49,"value":815},"public sealed record ProductResponse(\n",{"type":43,"tag":647,"props":817,"children":818},{"class":649,"line":668},[819],{"type":43,"tag":647,"props":820,"children":821},{},[822],{"type":49,"value":823},"    int Id,\n",{"type":43,"tag":647,"props":825,"children":826},{"class":649,"line":677},[827],{"type":43,"tag":647,"props":828,"children":829},{},[830],{"type":49,"value":831},"    string Name,\n",{"type":43,"tag":647,"props":833,"children":834},{"class":649,"line":686},[835],{"type":43,"tag":647,"props":836,"children":837},{},[838],{"type":49,"value":839},"    decimal Price,\n",{"type":43,"tag":647,"props":841,"children":842},{"class":649,"line":695},[843],{"type":43,"tag":647,"props":844,"children":845},{},[846],{"type":49,"value":847},"    Category Category,\n",{"type":43,"tag":647,"props":849,"children":850},{"class":649,"line":704},[851],{"type":43,"tag":647,"props":852,"children":853},{},[854],{"type":49,"value":855},"    bool IsAvailable,\n",{"type":43,"tag":647,"props":857,"children":858},{"class":649,"line":713},[859],{"type":43,"tag":647,"props":860,"children":861},{},[862],{"type":49,"value":863},"    DateTimeOffset CreatedAt);\n",{"type":43,"tag":52,"props":865,"children":866},{},[867,872,874,880],{"type":43,"tag":324,"props":868,"children":869},{},[870],{"type":49,"value":871},"Request DTOs",{"type":49,"value":873}," — use sealed records with ",{"type":43,"tag":95,"props":875,"children":877},{"className":876},[],[878],{"type":49,"value":879},"init",{"type":49,"value":881}," properties so data annotations\nwork naturally:",{"type":43,"tag":636,"props":883,"children":885},{"className":638,"code":884,"language":640,"meta":641,"style":641},"\u002F\u002F\u002F \u003Csummary>Payload for creating a new product.\u003C\u002Fsummary>\npublic sealed record CreateProductRequest\n{\n    [Required, MaxLength(200)]\n    public required string Name { get; init; }\n\n    [Range(0.01, 999999.99)]\n    public required decimal Price { get; init; }\n\n    public required Category Category { get; init; }\n}\n",[886],{"type":43,"tag":95,"props":887,"children":888},{"__ignoreMap":641},[889,897,905,912,920,928,937,945,953,960,968],{"type":43,"tag":647,"props":890,"children":891},{"class":649,"line":650},[892],{"type":43,"tag":647,"props":893,"children":894},{},[895],{"type":49,"value":896},"\u002F\u002F\u002F \u003Csummary>Payload for creating a new product.\u003C\u002Fsummary>\n",{"type":43,"tag":647,"props":898,"children":899},{"class":649,"line":659},[900],{"type":43,"tag":647,"props":901,"children":902},{},[903],{"type":49,"value":904},"public sealed record CreateProductRequest\n",{"type":43,"tag":647,"props":906,"children":907},{"class":649,"line":668},[908],{"type":43,"tag":647,"props":909,"children":910},{},[911],{"type":49,"value":683},{"type":43,"tag":647,"props":913,"children":914},{"class":649,"line":677},[915],{"type":43,"tag":647,"props":916,"children":917},{},[918],{"type":49,"value":919},"    [Required, MaxLength(200)]\n",{"type":43,"tag":647,"props":921,"children":922},{"class":649,"line":686},[923],{"type":43,"tag":647,"props":924,"children":925},{},[926],{"type":49,"value":927},"    public required string Name { get; init; }\n",{"type":43,"tag":647,"props":929,"children":930},{"class":649,"line":695},[931],{"type":43,"tag":647,"props":932,"children":934},{"emptyLinePlaceholder":933},true,[935],{"type":49,"value":936},"\n",{"type":43,"tag":647,"props":938,"children":939},{"class":649,"line":704},[940],{"type":43,"tag":647,"props":941,"children":942},{},[943],{"type":49,"value":944},"    [Range(0.01, 999999.99)]\n",{"type":43,"tag":647,"props":946,"children":947},{"class":649,"line":713},[948],{"type":43,"tag":647,"props":949,"children":950},{},[951],{"type":49,"value":952},"    public required decimal Price { get; init; }\n",{"type":43,"tag":647,"props":954,"children":955},{"class":649,"line":722},[956],{"type":43,"tag":647,"props":957,"children":958},{"emptyLinePlaceholder":933},[959],{"type":49,"value":936},{"type":43,"tag":647,"props":961,"children":962},{"class":649,"line":731},[963],{"type":43,"tag":647,"props":964,"children":965},{},[966],{"type":49,"value":967},"    public required Category Category { get; init; }\n",{"type":43,"tag":647,"props":969,"children":970},{"class":649,"line":740},[971],{"type":43,"tag":647,"props":972,"children":973},{},[974],{"type":49,"value":975},"}\n",{"type":43,"tag":52,"props":977,"children":978},{},[979,981,986,988,994],{"type":49,"value":980},"Follow the same pattern for ",{"type":43,"tag":95,"props":982,"children":984},{"className":983},[],[985],{"type":49,"value":471},{"type":49,"value":987}," records, adding any\nadditional properties the update requires (e.g., ",{"type":43,"tag":95,"props":989,"children":991},{"className":990},[],[992],{"type":49,"value":993},"IsAvailable",{"type":49,"value":995},").",{"type":43,"tag":52,"props":997,"children":998},{},[999,1004,1006,1012,1013,1019,1020,1026,1028,1033,1035,1040],{"type":43,"tag":324,"props":1000,"children":1001},{},[1002],{"type":49,"value":1003},"Minimal API validation — register explicitly:",{"type":49,"value":1005}," Data-annotation validation\n(",{"type":43,"tag":95,"props":1007,"children":1009},{"className":1008},[],[1010],{"type":49,"value":1011},"[Required]",{"type":49,"value":213},{"type":43,"tag":95,"props":1014,"children":1016},{"className":1015},[],[1017],{"type":49,"value":1018},"[MaxLength]",{"type":49,"value":213},{"type":43,"tag":95,"props":1021,"children":1023},{"className":1022},[],[1024],{"type":49,"value":1025},"[Range]",{"type":49,"value":1027},", etc.) is automatic in MVC controllers,\nbut minimal APIs require explicit opt-in. For ",{"type":43,"tag":324,"props":1029,"children":1030},{},[1031],{"type":49,"value":1032},".NET 10+",{"type":49,"value":1034}," projects using minimal\nAPIs, add the validation services in ",{"type":43,"tag":95,"props":1036,"children":1038},{"className":1037},[],[1039],{"type":49,"value":179},{"type":49,"value":579},{"type":43,"tag":636,"props":1042,"children":1044},{"className":638,"code":1043,"language":640,"meta":641,"style":641},"builder.Services.AddValidation();\n",[1045],{"type":43,"tag":95,"props":1046,"children":1047},{"__ignoreMap":641},[1048],{"type":43,"tag":647,"props":1049,"children":1050},{"class":649,"line":650},[1051],{"type":43,"tag":647,"props":1052,"children":1053},{},[1054],{"type":49,"value":1043},{"type":43,"tag":52,"props":1056,"children":1057},{},[1058,1060,1066],{"type":49,"value":1059},"This wires up an endpoint filter that validates parameters decorated with data\nannotations before the handler executes, returning a ",{"type":43,"tag":95,"props":1061,"children":1063},{"className":1062},[],[1064],{"type":49,"value":1065},"400 Bad Request",{"type":49,"value":1067}," with a\nvalidation problem details response on failure.",{"type":43,"tag":52,"props":1069,"children":1070},{},[1071,1072],{"type":49,"value":555},{"type":43,"tag":557,"props":1073,"children":1076},{"href":1074,"rel":1075},"https:\u002F\u002Flearn.microsoft.com\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fminimal-apis?view=aspnetcore-10.0",[561],[1077],{"type":49,"value":1074},{"type":43,"tag":52,"props":1079,"children":1080},{},[1081,1086,1088,1094],{"type":43,"tag":324,"props":1082,"children":1083},{},[1084],{"type":49,"value":1085},"Do not",{"type":49,"value":1087}," use mutable classes (",{"type":43,"tag":95,"props":1089,"children":1091},{"className":1090},[],[1092],{"type":49,"value":1093},"{ get; set; }",{"type":49,"value":1095},") for DTOs. Mutable DTOs allow\naccidental modification after construction and lose the self-documenting\nimmutability that records provide.",{"type":43,"tag":259,"props":1097,"children":1099},{"id":1098},"step-3-implement-the-endpoints",[1100],{"type":49,"value":1101},"Step 3: Implement the endpoints",{"type":43,"tag":52,"props":1103,"children":1104},{},[1105],{"type":49,"value":1106},"Whether using controllers or minimal APIs, follow these HTTP conventions\nconsistently.",{"type":43,"tag":52,"props":1108,"children":1109},{},[1110,1115,1117,1123],{"type":43,"tag":324,"props":1111,"children":1112},{},[1113],{"type":49,"value":1114},"Organizing minimal API endpoints:",{"type":49,"value":1116}," For projects using minimal APIs, organize\nendpoints by resource using static classes with a static ",{"type":43,"tag":95,"props":1118,"children":1120},{"className":1119},[],[1121],{"type":49,"value":1122},"Map\u003CResource>",{"type":49,"value":1124}," method.\nThis pattern keeps endpoint definitions grouped by resource type, making the\ncode more maintainable and easier to navigate as the API grows.",{"type":43,"tag":52,"props":1126,"children":1127},{},[1128],{"type":43,"tag":324,"props":1129,"children":1130},{},[1131],{"type":49,"value":1132},"Pattern structure:",{"type":43,"tag":271,"props":1134,"children":1135},{},[1136,1155,1168,1202],{"type":43,"tag":74,"props":1137,"children":1138},{},[1139,1141,1147,1148,1154],{"type":49,"value":1140},"Create one static class per resource (e.g., ",{"type":43,"tag":95,"props":1142,"children":1144},{"className":1143},[],[1145],{"type":49,"value":1146},"ProductEndpoints",{"type":49,"value":213},{"type":43,"tag":95,"props":1149,"children":1151},{"className":1150},[],[1152],{"type":49,"value":1153},"CategoryEndpoints",{"type":49,"value":995},{"type":43,"tag":74,"props":1156,"children":1157},{},[1158,1160,1166],{"type":49,"value":1159},"Define a static ",{"type":43,"tag":95,"props":1161,"children":1163},{"className":1162},[],[1164],{"type":49,"value":1165},"Map\u003CResource>(this WebApplication app)",{"type":49,"value":1167}," extension method.",{"type":43,"tag":74,"props":1169,"children":1170},{},[1171,1173,1179,1180,1186,1187,1193,1194,1200],{"type":49,"value":1172},"Inside the method, call ",{"type":43,"tag":95,"props":1174,"children":1176},{"className":1175},[],[1177],{"type":49,"value":1178},"MapGet",{"type":49,"value":213},{"type":43,"tag":95,"props":1181,"children":1183},{"className":1182},[],[1184],{"type":49,"value":1185},"MapPost",{"type":49,"value":213},{"type":43,"tag":95,"props":1188,"children":1190},{"className":1189},[],[1191],{"type":49,"value":1192},"MapPut",{"type":49,"value":213},{"type":43,"tag":95,"props":1195,"children":1197},{"className":1196},[],[1198],{"type":49,"value":1199},"MapDelete",{"type":49,"value":1201},", etc. for\nthat resource's endpoints.",{"type":43,"tag":74,"props":1203,"children":1204},{},[1205,1207,1212,1214,1220],{"type":49,"value":1206},"In ",{"type":43,"tag":95,"props":1208,"children":1210},{"className":1209},[],[1211],{"type":49,"value":179},{"type":49,"value":1213},", call each resource's ",{"type":43,"tag":95,"props":1215,"children":1217},{"className":1216},[],[1218],{"type":49,"value":1219},"Map",{"type":49,"value":1221}," method in order.",{"type":43,"tag":52,"props":1223,"children":1224},{},[1225],{"type":43,"tag":324,"props":1226,"children":1227},{},[1228,1230,1236],{"type":49,"value":1229},"Minimal API return types — prefer ",{"type":43,"tag":95,"props":1231,"children":1233},{"className":1232},[],[1234],{"type":49,"value":1235},"TypedResults",{"type":49,"value":579},{"type":43,"tag":52,"props":1238,"children":1239},{},[1240,1242,1247,1249,1255,1257,1262],{"type":49,"value":1241},"Always prefer ",{"type":43,"tag":95,"props":1243,"children":1245},{"className":1244},[],[1246],{"type":49,"value":1235},{"type":49,"value":1248}," over the ",{"type":43,"tag":95,"props":1250,"children":1252},{"className":1251},[],[1253],{"type":49,"value":1254},"Results",{"type":49,"value":1256}," factory. ",{"type":43,"tag":95,"props":1258,"children":1260},{"className":1259},[],[1261],{"type":49,"value":1235},{"type":49,"value":1263}," embeds\nresponse type information in the method signature, giving the OpenAPI generator\nricher metadata automatically.",{"type":43,"tag":52,"props":1265,"children":1266},{},[1267,1269,1274,1276,1282,1284,1290,1292,1298,1300,1305],{"type":49,"value":1268},"When a handler returns ",{"type":43,"tag":324,"props":1270,"children":1271},{},[1272],{"type":49,"value":1273},"multiple result types",{"type":49,"value":1275}," (e.g., ",{"type":43,"tag":95,"props":1277,"children":1279},{"className":1278},[],[1280],{"type":49,"value":1281},"Ok",{"type":49,"value":1283}," or ",{"type":43,"tag":95,"props":1285,"children":1287},{"className":1286},[],[1288],{"type":49,"value":1289},"NotFound",{"type":49,"value":1291},"),\nannotate the lambda with an explicit ",{"type":43,"tag":95,"props":1293,"children":1295},{"className":1294},[],[1296],{"type":49,"value":1297},"Results\u003CT1, T2>",{"type":49,"value":1299}," return type. This\nlets you use ",{"type":43,"tag":95,"props":1301,"children":1303},{"className":1302},[],[1304],{"type":49,"value":1235},{"type":49,"value":1306}," while still giving the compiler a common type:",{"type":43,"tag":636,"props":1308,"children":1310},{"className":638,"code":1309,"language":640,"meta":641,"style":641},"async Task\u003CResults\u003COk\u003CProductResponse>, NotFound>> (int id, ...) => ...\n",[1311],{"type":43,"tag":95,"props":1312,"children":1313},{"__ignoreMap":641},[1314],{"type":43,"tag":647,"props":1315,"children":1316},{"class":649,"line":650},[1317],{"type":43,"tag":647,"props":1318,"children":1319},{},[1320],{"type":49,"value":1309},{"type":43,"tag":52,"props":1322,"children":1323},{},[1324,1328,1330,1336,1338,1344,1346,1352,1353,1358,1360,1366,1368,1374],{"type":43,"tag":324,"props":1325,"children":1326},{},[1327],{"type":49,"value":1085},{"type":49,"value":1329}," use ",{"type":43,"tag":95,"props":1331,"children":1333},{"className":1332},[],[1334],{"type":49,"value":1335},"TypedResults.Ok(x)",{"type":49,"value":1337}," and ",{"type":43,"tag":95,"props":1339,"children":1341},{"className":1340},[],[1342],{"type":49,"value":1343},"TypedResults.NotFound()",{"type":49,"value":1345}," in a bare\nternary without an explicit return type annotation. ",{"type":43,"tag":95,"props":1347,"children":1349},{"className":1348},[],[1350],{"type":49,"value":1351},"Ok\u003CT>",{"type":49,"value":1337},{"type":43,"tag":95,"props":1354,"children":1356},{"className":1355},[],[1357],{"type":49,"value":1289},{"type":49,"value":1359}," are\ndifferent types with no common base the compiler can infer, which causes\n",{"type":43,"tag":95,"props":1361,"children":1363},{"className":1362},[],[1364],{"type":49,"value":1365},"CS1593: Delegate 'RequestDelegate' does not take N arguments",{"type":49,"value":1367}," because the\ncompiler falls back to matching ",{"type":43,"tag":95,"props":1369,"children":1371},{"className":1370},[],[1372],{"type":49,"value":1373},"RequestDelegate(HttpContext)",{"type":49,"value":292},{"type":43,"tag":52,"props":1376,"children":1377},{},[1378,1390,1392,1397,1399,1405,1406,1412,1414,1420],{"type":43,"tag":324,"props":1379,"children":1380},{},[1381,1383,1388],{"type":49,"value":1382},"Fallback — ",{"type":43,"tag":95,"props":1384,"children":1386},{"className":1385},[],[1387],{"type":49,"value":1254},{"type":49,"value":1389}," factory:",{"type":49,"value":1391}," If a handler has many conditional branches\n(7+ result types), you may use the ",{"type":43,"tag":95,"props":1393,"children":1395},{"className":1394},[],[1396],{"type":49,"value":1254},{"type":49,"value":1398}," factory (",{"type":43,"tag":95,"props":1400,"children":1402},{"className":1401},[],[1403],{"type":49,"value":1404},"Results.Ok()",{"type":49,"value":221},{"type":43,"tag":95,"props":1407,"children":1409},{"className":1408},[],[1410],{"type":49,"value":1411},"Results.NotFound()",{"type":49,"value":1413},") which returns ",{"type":43,"tag":95,"props":1415,"children":1417},{"className":1416},[],[1418],{"type":49,"value":1419},"IResult",{"type":49,"value":1421},", sacrificing compile-time OpenAPI\ninference for simpler signatures.",{"type":43,"tag":52,"props":1423,"children":1424},{},[1425],{"type":43,"tag":324,"props":1426,"children":1427},{},[1428],{"type":49,"value":1429},"Status codes:",{"type":43,"tag":397,"props":1431,"children":1432},{},[1433,1454],{"type":43,"tag":401,"props":1434,"children":1435},{},[1436],{"type":43,"tag":405,"props":1437,"children":1438},{},[1439,1444,1449],{"type":43,"tag":409,"props":1440,"children":1441},{},[1442],{"type":49,"value":1443},"Operation",{"type":43,"tag":409,"props":1445,"children":1446},{},[1447],{"type":49,"value":1448},"Success",{"type":43,"tag":409,"props":1450,"children":1451},{},[1452],{"type":49,"value":1453},"Common errors",{"type":43,"tag":425,"props":1455,"children":1456},{},[1457,1483,1504,1546,1576,1606],{"type":43,"tag":405,"props":1458,"children":1459},{},[1460,1465,1474],{"type":43,"tag":432,"props":1461,"children":1462},{},[1463],{"type":49,"value":1464},"GET (single)",{"type":43,"tag":432,"props":1466,"children":1467},{},[1468],{"type":43,"tag":95,"props":1469,"children":1471},{"className":1470},[],[1472],{"type":49,"value":1473},"200 OK",{"type":43,"tag":432,"props":1475,"children":1476},{},[1477],{"type":43,"tag":95,"props":1478,"children":1480},{"className":1479},[],[1481],{"type":49,"value":1482},"404 Not Found",{"type":43,"tag":405,"props":1484,"children":1485},{},[1486,1491,1499],{"type":43,"tag":432,"props":1487,"children":1488},{},[1489],{"type":49,"value":1490},"GET (list)",{"type":43,"tag":432,"props":1492,"children":1493},{},[1494],{"type":43,"tag":95,"props":1495,"children":1497},{"className":1496},[],[1498],{"type":49,"value":1473},{"type":43,"tag":432,"props":1500,"children":1501},{},[1502],{"type":49,"value":1503},"—",{"type":43,"tag":405,"props":1505,"children":1506},{},[1507,1512,1531],{"type":43,"tag":432,"props":1508,"children":1509},{},[1510],{"type":49,"value":1511},"POST (create)",{"type":43,"tag":432,"props":1513,"children":1514},{},[1515,1521,1523,1529],{"type":43,"tag":95,"props":1516,"children":1518},{"className":1517},[],[1519],{"type":49,"value":1520},"201 Created",{"type":49,"value":1522}," with ",{"type":43,"tag":95,"props":1524,"children":1526},{"className":1525},[],[1527],{"type":49,"value":1528},"Location",{"type":49,"value":1530}," header",{"type":43,"tag":432,"props":1532,"children":1533},{},[1534,1539,1540],{"type":43,"tag":95,"props":1535,"children":1537},{"className":1536},[],[1538],{"type":49,"value":1065},{"type":49,"value":213},{"type":43,"tag":95,"props":1541,"children":1543},{"className":1542},[],[1544],{"type":49,"value":1545},"409 Conflict",{"type":43,"tag":405,"props":1547,"children":1548},{},[1549,1554,1562],{"type":43,"tag":432,"props":1550,"children":1551},{},[1552],{"type":49,"value":1553},"PUT (full update)",{"type":43,"tag":432,"props":1555,"children":1556},{},[1557],{"type":43,"tag":95,"props":1558,"children":1560},{"className":1559},[],[1561],{"type":49,"value":1473},{"type":43,"tag":432,"props":1563,"children":1564},{},[1565,1570,1571],{"type":43,"tag":95,"props":1566,"children":1568},{"className":1567},[],[1569],{"type":49,"value":1065},{"type":49,"value":213},{"type":43,"tag":95,"props":1572,"children":1574},{"className":1573},[],[1575],{"type":49,"value":1482},{"type":43,"tag":405,"props":1577,"children":1578},{},[1579,1584,1592],{"type":43,"tag":432,"props":1580,"children":1581},{},[1582],{"type":49,"value":1583},"PATCH (partial\u002Faction)",{"type":43,"tag":432,"props":1585,"children":1586},{},[1587],{"type":43,"tag":95,"props":1588,"children":1590},{"className":1589},[],[1591],{"type":49,"value":1473},{"type":43,"tag":432,"props":1593,"children":1594},{},[1595,1600,1601],{"type":43,"tag":95,"props":1596,"children":1598},{"className":1597},[],[1599],{"type":49,"value":1065},{"type":49,"value":213},{"type":43,"tag":95,"props":1602,"children":1604},{"className":1603},[],[1605],{"type":49,"value":1482},{"type":43,"tag":405,"props":1607,"children":1608},{},[1609,1614,1623],{"type":43,"tag":432,"props":1610,"children":1611},{},[1612],{"type":49,"value":1613},"DELETE",{"type":43,"tag":432,"props":1615,"children":1616},{},[1617],{"type":43,"tag":95,"props":1618,"children":1620},{"className":1619},[],[1621],{"type":49,"value":1622},"204 No Content",{"type":43,"tag":432,"props":1624,"children":1625},{},[1626,1631,1632],{"type":43,"tag":95,"props":1627,"children":1629},{"className":1628},[],[1630],{"type":49,"value":1482},{"type":49,"value":213},{"type":43,"tag":95,"props":1633,"children":1635},{"className":1634},[],[1636],{"type":49,"value":1545},{"type":43,"tag":52,"props":1638,"children":1639},{},[1640,1645,1647,1652],{"type":43,"tag":324,"props":1641,"children":1642},{},[1643],{"type":49,"value":1644},"POST 201 responses:",{"type":49,"value":1646}," Always return a ",{"type":43,"tag":95,"props":1648,"children":1650},{"className":1649},[],[1651],{"type":49,"value":1528},{"type":49,"value":1653}," header pointing to the\nnewly created resource.",{"type":43,"tag":70,"props":1655,"children":1656},{},[1657,1668],{"type":43,"tag":74,"props":1658,"children":1659},{},[1660,1662],{"type":49,"value":1661},"Controllers: use ",{"type":43,"tag":95,"props":1663,"children":1665},{"className":1664},[],[1666],{"type":49,"value":1667},"CreatedAtAction(nameof(GetById), new { id = ... }, response)",{"type":43,"tag":74,"props":1669,"children":1670},{},[1671,1673],{"type":49,"value":1672},"Minimal APIs: use ",{"type":43,"tag":95,"props":1674,"children":1676},{"className":1675},[],[1677],{"type":49,"value":1678},"TypedResults.Created($\"\u002Fapi\u002Fproducts\u002F{id}\", response)",{"type":43,"tag":52,"props":1680,"children":1681},{},[1682,1687,1689,1695,1697,1703],{"type":43,"tag":324,"props":1683,"children":1684},{},[1685],{"type":49,"value":1686},"CancellationToken:",{"type":49,"value":1688}," Accept ",{"type":43,"tag":95,"props":1690,"children":1692},{"className":1691},[],[1693],{"type":49,"value":1694},"CancellationToken",{"type":49,"value":1696}," in every endpoint signature\nand forward it through to all async calls (service methods, EF Core queries,\n",{"type":43,"tag":95,"props":1698,"children":1700},{"className":1699},[],[1701],{"type":49,"value":1702},"HttpClient",{"type":49,"value":1704}," calls). This allows the server to stop work when a client\ndisconnects.",{"type":43,"tag":636,"props":1706,"children":1708},{"className":638,"code":1707,"language":640,"meta":641,"style":641},"\u002F\u002F Controller example\n[HttpGet(\"{id}\")]\npublic async Task\u003CActionResult\u003CProductResponse>> GetById(\n    int id, CancellationToken cancellationToken)\n{\n    var product = await _productService.GetByIdAsync(id, cancellationToken);\n    return product is null ? NotFound() : Ok(product);\n}\n\n\u002F\u002F Minimal API example — TypedResults with explicit return type (recommended)\napp.MapGet(\"\u002Fapi\u002Fproducts\u002F{id}\", async Task\u003CResults\u003COk\u003CProductResponse>, NotFound>> (\n    int id, IProductService service, CancellationToken cancellationToken) =>\n{\n    var product = await service.GetByIdAsync(id, cancellationToken);\n    return product is null ? TypedResults.NotFound() : TypedResults.Ok(product);\n});\n",[1709],{"type":43,"tag":95,"props":1710,"children":1711},{"__ignoreMap":641},[1712,1720,1728,1736,1744,1751,1759,1767,1774,1781,1789,1797,1805,1812,1821,1830],{"type":43,"tag":647,"props":1713,"children":1714},{"class":649,"line":650},[1715],{"type":43,"tag":647,"props":1716,"children":1717},{},[1718],{"type":49,"value":1719},"\u002F\u002F Controller example\n",{"type":43,"tag":647,"props":1721,"children":1722},{"class":649,"line":659},[1723],{"type":43,"tag":647,"props":1724,"children":1725},{},[1726],{"type":49,"value":1727},"[HttpGet(\"{id}\")]\n",{"type":43,"tag":647,"props":1729,"children":1730},{"class":649,"line":668},[1731],{"type":43,"tag":647,"props":1732,"children":1733},{},[1734],{"type":49,"value":1735},"public async Task\u003CActionResult\u003CProductResponse>> GetById(\n",{"type":43,"tag":647,"props":1737,"children":1738},{"class":649,"line":677},[1739],{"type":43,"tag":647,"props":1740,"children":1741},{},[1742],{"type":49,"value":1743},"    int id, CancellationToken cancellationToken)\n",{"type":43,"tag":647,"props":1745,"children":1746},{"class":649,"line":686},[1747],{"type":43,"tag":647,"props":1748,"children":1749},{},[1750],{"type":49,"value":683},{"type":43,"tag":647,"props":1752,"children":1753},{"class":649,"line":695},[1754],{"type":43,"tag":647,"props":1755,"children":1756},{},[1757],{"type":49,"value":1758},"    var product = await _productService.GetByIdAsync(id, cancellationToken);\n",{"type":43,"tag":647,"props":1760,"children":1761},{"class":649,"line":704},[1762],{"type":43,"tag":647,"props":1763,"children":1764},{},[1765],{"type":49,"value":1766},"    return product is null ? NotFound() : Ok(product);\n",{"type":43,"tag":647,"props":1768,"children":1769},{"class":649,"line":713},[1770],{"type":43,"tag":647,"props":1771,"children":1772},{},[1773],{"type":49,"value":975},{"type":43,"tag":647,"props":1775,"children":1776},{"class":649,"line":722},[1777],{"type":43,"tag":647,"props":1778,"children":1779},{"emptyLinePlaceholder":933},[1780],{"type":49,"value":936},{"type":43,"tag":647,"props":1782,"children":1783},{"class":649,"line":731},[1784],{"type":43,"tag":647,"props":1785,"children":1786},{},[1787],{"type":49,"value":1788},"\u002F\u002F Minimal API example — TypedResults with explicit return type (recommended)\n",{"type":43,"tag":647,"props":1790,"children":1791},{"class":649,"line":740},[1792],{"type":43,"tag":647,"props":1793,"children":1794},{},[1795],{"type":49,"value":1796},"app.MapGet(\"\u002Fapi\u002Fproducts\u002F{id}\", async Task\u003CResults\u003COk\u003CProductResponse>, NotFound>> (\n",{"type":43,"tag":647,"props":1798,"children":1799},{"class":649,"line":749},[1800],{"type":43,"tag":647,"props":1801,"children":1802},{},[1803],{"type":49,"value":1804},"    int id, IProductService service, CancellationToken cancellationToken) =>\n",{"type":43,"tag":647,"props":1806,"children":1807},{"class":649,"line":758},[1808],{"type":43,"tag":647,"props":1809,"children":1810},{},[1811],{"type":49,"value":683},{"type":43,"tag":647,"props":1813,"children":1815},{"class":649,"line":1814},14,[1816],{"type":43,"tag":647,"props":1817,"children":1818},{},[1819],{"type":49,"value":1820},"    var product = await service.GetByIdAsync(id, cancellationToken);\n",{"type":43,"tag":647,"props":1822,"children":1824},{"class":649,"line":1823},15,[1825],{"type":43,"tag":647,"props":1826,"children":1827},{},[1828],{"type":49,"value":1829},"    return product is null ? TypedResults.NotFound() : TypedResults.Ok(product);\n",{"type":43,"tag":647,"props":1831,"children":1833},{"class":649,"line":1832},16,[1834],{"type":43,"tag":647,"props":1835,"children":1836},{},[1837],{"type":49,"value":764},{"type":43,"tag":259,"props":1839,"children":1841},{"id":1840},"step-4-wire-up-openapi",[1842],{"type":49,"value":1843},"Step 4: Wire up OpenAPI",{"type":43,"tag":52,"props":1845,"children":1846},{},[1847],{"type":49,"value":1848},"Every ASP.NET Core Web API should have OpenAPI documentation. Check whether\nthe project already has OpenAPI configured before adding it.",{"type":43,"tag":52,"props":1850,"children":1851},{},[1852,1857,1859,1865,1867,1873],{"type":43,"tag":324,"props":1853,"children":1854},{},[1855],{"type":49,"value":1856},"For .NET 9+ projects",{"type":49,"value":1858},", use the built-in ASP.NET Core OpenAPI support\n(",{"type":43,"tag":95,"props":1860,"children":1862},{"className":1861},[],[1863],{"type":49,"value":1864},"builder.Services.AddOpenApi()",{"type":49,"value":1866}," + ",{"type":43,"tag":95,"props":1868,"children":1870},{"className":1869},[],[1871],{"type":49,"value":1872},"app.MapOpenApi()",{"type":49,"value":1874}," in development).\nThis is all that is needed — no additional packages required.",{"type":43,"tag":52,"props":1876,"children":1877},{},[1878,1891,1893,1899,1900,1906,1907,1913],{"type":43,"tag":324,"props":1879,"children":1880},{},[1881,1883,1889],{"type":49,"value":1882},"Do NOT add any ",{"type":43,"tag":95,"props":1884,"children":1886},{"className":1885},[],[1887],{"type":49,"value":1888},"Swashbuckle.*",{"type":49,"value":1890}," NuGet package",{"type":49,"value":1892}," (",{"type":43,"tag":95,"props":1894,"children":1896},{"className":1895},[],[1897],{"type":49,"value":1898},"Swashbuckle.AspNetCore",{"type":49,"value":221},{"type":43,"tag":95,"props":1901,"children":1903},{"className":1902},[],[1904],{"type":49,"value":1905},"Swashbuckle.AspNetCore.SwaggerUI",{"type":49,"value":213},{"type":43,"tag":95,"props":1908,"children":1910},{"className":1909},[],[1911],{"type":49,"value":1912},"Swashbuckle.AspNetCore.SwaggerGen",{"type":49,"value":1914},",\netc.) to .NET 9+ projects. Swashbuckle has known compatibility issues with\n.NET 9+ and .NET 10 OpenAPI types. For projects targeting .NET 8 or earlier,\nSwashbuckle is acceptable. If the project already has Swashbuckle installed,\nkeep it unless the user asks to remove it.",{"type":43,"tag":52,"props":1916,"children":1917},{},[1918,1919],{"type":49,"value":555},{"type":43,"tag":557,"props":1920,"children":1923},{"href":1921,"rel":1922},"https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fopenapi\u002Foverview",[561],[1924],{"type":49,"value":1921},{"type":43,"tag":52,"props":1926,"children":1927},{},[1928,1933],{"type":43,"tag":324,"props":1929,"children":1930},{},[1931],{"type":49,"value":1932},"OpenAPI metadata on endpoints:",{"type":49,"value":1934}," Add descriptive metadata so the generated\ndocumentation is useful, not just a list of routes. For minimal APIs, chain\nthe metadata methods:",{"type":43,"tag":636,"props":1936,"children":1938},{"className":638,"code":1937,"language":640,"meta":641,"style":641},"app.MapGet(\"\u002Fapi\u002Fproducts\u002F{id}\", handler)\n    .WithName(\"GetProductById\")\n    .WithSummary(\"Get a product by ID\")\n    .WithDescription(\"Returns the full product details including category.\")\n    .Produces\u003CProductResponse>(StatusCodes.Status200OK)\n    .Produces(StatusCodes.Status404NotFound);\n",[1939],{"type":43,"tag":95,"props":1940,"children":1941},{"__ignoreMap":641},[1942,1950,1958,1966,1974,1982],{"type":43,"tag":647,"props":1943,"children":1944},{"class":649,"line":650},[1945],{"type":43,"tag":647,"props":1946,"children":1947},{},[1948],{"type":49,"value":1949},"app.MapGet(\"\u002Fapi\u002Fproducts\u002F{id}\", handler)\n",{"type":43,"tag":647,"props":1951,"children":1952},{"class":649,"line":659},[1953],{"type":43,"tag":647,"props":1954,"children":1955},{},[1956],{"type":49,"value":1957},"    .WithName(\"GetProductById\")\n",{"type":43,"tag":647,"props":1959,"children":1960},{"class":649,"line":668},[1961],{"type":43,"tag":647,"props":1962,"children":1963},{},[1964],{"type":49,"value":1965},"    .WithSummary(\"Get a product by ID\")\n",{"type":43,"tag":647,"props":1967,"children":1968},{"class":649,"line":677},[1969],{"type":43,"tag":647,"props":1970,"children":1971},{},[1972],{"type":49,"value":1973},"    .WithDescription(\"Returns the full product details including category.\")\n",{"type":43,"tag":647,"props":1975,"children":1976},{"class":649,"line":686},[1977],{"type":43,"tag":647,"props":1978,"children":1979},{},[1980],{"type":49,"value":1981},"    .Produces\u003CProductResponse>(StatusCodes.Status200OK)\n",{"type":43,"tag":647,"props":1983,"children":1984},{"class":649,"line":695},[1985],{"type":43,"tag":647,"props":1986,"children":1987},{},[1988],{"type":49,"value":1989},"    .Produces(StatusCodes.Status404NotFound);\n",{"type":43,"tag":52,"props":1991,"children":1992},{},[1993,1998],{"type":43,"tag":324,"props":1994,"children":1995},{},[1996],{"type":49,"value":1997},"Enum serialization (strings by default):",{"type":49,"value":1999}," Configure JSON serialization so\nenums appear as readable strings in both API responses and OpenAPI schemas.\nAlways add this configuration unless the user explicitly requests integer\nenum serialization. Configure it for both minimal APIs and controllers, as\nthey use different option types:",{"type":43,"tag":636,"props":2001,"children":2003},{"className":638,"code":2002,"language":640,"meta":641,"style":641},"\u002F\u002F Minimal APIs\nbuilder.Services.ConfigureHttpJsonOptions(options =>\n    options.SerializerOptions.Converters.Add(new JsonStringEnumConverter()));\n\n\u002F\u002F Controllers \u002F MVC\nbuilder.Services.AddControllers()\n    .AddJsonOptions(options =>\n    {\n        options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());\n    });\n",[2004],{"type":43,"tag":95,"props":2005,"children":2006},{"__ignoreMap":641},[2007,2015,2022,2030,2037,2045,2053,2061,2069,2077],{"type":43,"tag":647,"props":2008,"children":2009},{"class":649,"line":650},[2010],{"type":43,"tag":647,"props":2011,"children":2012},{},[2013],{"type":49,"value":2014},"\u002F\u002F Minimal APIs\n",{"type":43,"tag":647,"props":2016,"children":2017},{"class":649,"line":659},[2018],{"type":43,"tag":647,"props":2019,"children":2020},{},[2021],{"type":49,"value":674},{"type":43,"tag":647,"props":2023,"children":2024},{"class":649,"line":668},[2025],{"type":43,"tag":647,"props":2026,"children":2027},{},[2028],{"type":49,"value":2029},"    options.SerializerOptions.Converters.Add(new JsonStringEnumConverter()));\n",{"type":43,"tag":647,"props":2031,"children":2032},{"class":649,"line":677},[2033],{"type":43,"tag":647,"props":2034,"children":2035},{"emptyLinePlaceholder":933},[2036],{"type":49,"value":936},{"type":43,"tag":647,"props":2038,"children":2039},{"class":649,"line":686},[2040],{"type":43,"tag":647,"props":2041,"children":2042},{},[2043],{"type":49,"value":2044},"\u002F\u002F Controllers \u002F MVC\n",{"type":43,"tag":647,"props":2046,"children":2047},{"class":649,"line":695},[2048],{"type":43,"tag":647,"props":2049,"children":2050},{},[2051],{"type":49,"value":2052},"builder.Services.AddControllers()\n",{"type":43,"tag":647,"props":2054,"children":2055},{"class":649,"line":704},[2056],{"type":43,"tag":647,"props":2057,"children":2058},{},[2059],{"type":49,"value":2060},"    .AddJsonOptions(options =>\n",{"type":43,"tag":647,"props":2062,"children":2063},{"class":649,"line":713},[2064],{"type":43,"tag":647,"props":2065,"children":2066},{},[2067],{"type":49,"value":2068},"    {\n",{"type":43,"tag":647,"props":2070,"children":2071},{"class":649,"line":722},[2072],{"type":43,"tag":647,"props":2073,"children":2074},{},[2075],{"type":49,"value":2076},"        options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());\n",{"type":43,"tag":647,"props":2078,"children":2079},{"class":649,"line":731},[2080],{"type":43,"tag":647,"props":2081,"children":2082},{},[2083],{"type":49,"value":2084},"    });\n",{"type":43,"tag":259,"props":2086,"children":2088},{"id":2087},"step-5-set-up-error-handling",[2089],{"type":49,"value":2090},"Step 5: Set up error handling",{"type":43,"tag":52,"props":2092,"children":2093},{},[2094],{"type":49,"value":2095},"Use a global exception handler so that individual endpoints do not need\ntry-catch blocks. Return RFC 7807 Problem Details for all error responses.",{"type":43,"tag":52,"props":2097,"children":2098},{},[2099,2104],{"type":43,"tag":324,"props":2100,"children":2101},{},[2102],{"type":49,"value":2103},"For .NET 8+ projects",{"type":49,"value":2105},", prefer the built-in exception handler middleware:",{"type":43,"tag":636,"props":2107,"children":2109},{"className":638,"code":2108,"language":640,"meta":641,"style":641},"builder.Services.AddProblemDetails();\n\napp.UseExceptionHandler();\napp.UseStatusCodePages();\n",[2110],{"type":43,"tag":95,"props":2111,"children":2112},{"__ignoreMap":641},[2113,2121,2128,2136],{"type":43,"tag":647,"props":2114,"children":2115},{"class":649,"line":650},[2116],{"type":43,"tag":647,"props":2117,"children":2118},{},[2119],{"type":49,"value":2120},"builder.Services.AddProblemDetails();\n",{"type":43,"tag":647,"props":2122,"children":2123},{"class":649,"line":659},[2124],{"type":43,"tag":647,"props":2125,"children":2126},{"emptyLinePlaceholder":933},[2127],{"type":49,"value":936},{"type":43,"tag":647,"props":2129,"children":2130},{"class":649,"line":668},[2131],{"type":43,"tag":647,"props":2132,"children":2133},{},[2134],{"type":49,"value":2135},"app.UseExceptionHandler();\n",{"type":43,"tag":647,"props":2137,"children":2138},{"class":649,"line":677},[2139],{"type":43,"tag":647,"props":2140,"children":2141},{},[2142],{"type":49,"value":2143},"app.UseStatusCodePages();\n",{"type":43,"tag":52,"props":2145,"children":2146},{},[2147,2149,2155,2157,2163],{"type":49,"value":2148},"If the project needs custom exception-to-status-code mapping (e.g., a\n",{"type":43,"tag":95,"props":2150,"children":2152},{"className":2151},[],[2153],{"type":49,"value":2154},"NotFoundException",{"type":49,"value":2156}," should return 404), implement ",{"type":43,"tag":95,"props":2158,"children":2160},{"className":2159},[],[2161],{"type":49,"value":2162},"IExceptionHandler",{"type":49,"value":579},{"type":43,"tag":636,"props":2165,"children":2167},{"className":638,"code":2166,"language":640,"meta":641,"style":641},"internal sealed class ApiExceptionHandler(ILogger\u003CApiExceptionHandler> logger)\n    : IExceptionHandler\n{\n    public async ValueTask\u003Cbool> TryHandleAsync(\n        HttpContext httpContext,\n        Exception exception,\n        CancellationToken cancellationToken)\n    {\n        var (statusCode, title) = exception switch\n        {\n            KeyNotFoundException => (StatusCodes.Status404NotFound, \"Not Found\"),\n            ArgumentException => (StatusCodes.Status400BadRequest, \"Bad Request\"),\n            InvalidOperationException => (StatusCodes.Status409Conflict, \"Conflict\"),\n            _ => (0, (string?)null)\n        };\n\n        if (statusCode == 0)\n            return false; \u002F\u002F Let the default handler deal with it\n\n        \u002F\u002F Important: returning true below suppresses the exception diagnostics middleware\n        \u002F\u002F for this exception, so ensure it is logged\u002Ftelemetrized before returning.\n        logger.LogWarning(exception, \"Handled API exception: {Title}\", title);\n\n        httpContext.Response.StatusCode = statusCode;\n        await httpContext.Response.WriteAsJsonAsync(new ProblemDetails\n        {\n            Status = statusCode,\n            Title = title,\n            \u002F\u002F Do not use exception.Message here — it may leak sensitive internal details.\n            \u002F\u002F Use a safe, user-facing message instead.\n            Detail = title,\n            Instance = httpContext.Request.Path\n        }, cancellationToken);\n\n        return true;\n    }\n}\n",[2168],{"type":43,"tag":95,"props":2169,"children":2170},{"__ignoreMap":641},[2171,2179,2187,2194,2202,2210,2218,2226,2233,2241,2249,2257,2265,2273,2281,2289,2296,2305,2314,2322,2331,2340,2349,2357,2366,2375,2383,2392,2401,2410,2419,2428,2437,2446,2454,2463,2472],{"type":43,"tag":647,"props":2172,"children":2173},{"class":649,"line":650},[2174],{"type":43,"tag":647,"props":2175,"children":2176},{},[2177],{"type":49,"value":2178},"internal sealed class ApiExceptionHandler(ILogger\u003CApiExceptionHandler> logger)\n",{"type":43,"tag":647,"props":2180,"children":2181},{"class":649,"line":659},[2182],{"type":43,"tag":647,"props":2183,"children":2184},{},[2185],{"type":49,"value":2186},"    : IExceptionHandler\n",{"type":43,"tag":647,"props":2188,"children":2189},{"class":649,"line":668},[2190],{"type":43,"tag":647,"props":2191,"children":2192},{},[2193],{"type":49,"value":683},{"type":43,"tag":647,"props":2195,"children":2196},{"class":649,"line":677},[2197],{"type":43,"tag":647,"props":2198,"children":2199},{},[2200],{"type":49,"value":2201},"    public async ValueTask\u003Cbool> TryHandleAsync(\n",{"type":43,"tag":647,"props":2203,"children":2204},{"class":649,"line":686},[2205],{"type":43,"tag":647,"props":2206,"children":2207},{},[2208],{"type":49,"value":2209},"        HttpContext httpContext,\n",{"type":43,"tag":647,"props":2211,"children":2212},{"class":649,"line":695},[2213],{"type":43,"tag":647,"props":2214,"children":2215},{},[2216],{"type":49,"value":2217},"        Exception exception,\n",{"type":43,"tag":647,"props":2219,"children":2220},{"class":649,"line":704},[2221],{"type":43,"tag":647,"props":2222,"children":2223},{},[2224],{"type":49,"value":2225},"        CancellationToken cancellationToken)\n",{"type":43,"tag":647,"props":2227,"children":2228},{"class":649,"line":713},[2229],{"type":43,"tag":647,"props":2230,"children":2231},{},[2232],{"type":49,"value":2068},{"type":43,"tag":647,"props":2234,"children":2235},{"class":649,"line":722},[2236],{"type":43,"tag":647,"props":2237,"children":2238},{},[2239],{"type":49,"value":2240},"        var (statusCode, title) = exception switch\n",{"type":43,"tag":647,"props":2242,"children":2243},{"class":649,"line":731},[2244],{"type":43,"tag":647,"props":2245,"children":2246},{},[2247],{"type":49,"value":2248},"        {\n",{"type":43,"tag":647,"props":2250,"children":2251},{"class":649,"line":740},[2252],{"type":43,"tag":647,"props":2253,"children":2254},{},[2255],{"type":49,"value":2256},"            KeyNotFoundException => (StatusCodes.Status404NotFound, \"Not Found\"),\n",{"type":43,"tag":647,"props":2258,"children":2259},{"class":649,"line":749},[2260],{"type":43,"tag":647,"props":2261,"children":2262},{},[2263],{"type":49,"value":2264},"            ArgumentException => (StatusCodes.Status400BadRequest, \"Bad Request\"),\n",{"type":43,"tag":647,"props":2266,"children":2267},{"class":649,"line":758},[2268],{"type":43,"tag":647,"props":2269,"children":2270},{},[2271],{"type":49,"value":2272},"            InvalidOperationException => (StatusCodes.Status409Conflict, \"Conflict\"),\n",{"type":43,"tag":647,"props":2274,"children":2275},{"class":649,"line":1814},[2276],{"type":43,"tag":647,"props":2277,"children":2278},{},[2279],{"type":49,"value":2280},"            _ => (0, (string?)null)\n",{"type":43,"tag":647,"props":2282,"children":2283},{"class":649,"line":1823},[2284],{"type":43,"tag":647,"props":2285,"children":2286},{},[2287],{"type":49,"value":2288},"        };\n",{"type":43,"tag":647,"props":2290,"children":2291},{"class":649,"line":1832},[2292],{"type":43,"tag":647,"props":2293,"children":2294},{"emptyLinePlaceholder":933},[2295],{"type":49,"value":936},{"type":43,"tag":647,"props":2297,"children":2299},{"class":649,"line":2298},17,[2300],{"type":43,"tag":647,"props":2301,"children":2302},{},[2303],{"type":49,"value":2304},"        if (statusCode == 0)\n",{"type":43,"tag":647,"props":2306,"children":2308},{"class":649,"line":2307},18,[2309],{"type":43,"tag":647,"props":2310,"children":2311},{},[2312],{"type":49,"value":2313},"            return false; \u002F\u002F Let the default handler deal with it\n",{"type":43,"tag":647,"props":2315,"children":2317},{"class":649,"line":2316},19,[2318],{"type":43,"tag":647,"props":2319,"children":2320},{"emptyLinePlaceholder":933},[2321],{"type":49,"value":936},{"type":43,"tag":647,"props":2323,"children":2325},{"class":649,"line":2324},20,[2326],{"type":43,"tag":647,"props":2327,"children":2328},{},[2329],{"type":49,"value":2330},"        \u002F\u002F Important: returning true below suppresses the exception diagnostics middleware\n",{"type":43,"tag":647,"props":2332,"children":2334},{"class":649,"line":2333},21,[2335],{"type":43,"tag":647,"props":2336,"children":2337},{},[2338],{"type":49,"value":2339},"        \u002F\u002F for this exception, so ensure it is logged\u002Ftelemetrized before returning.\n",{"type":43,"tag":647,"props":2341,"children":2343},{"class":649,"line":2342},22,[2344],{"type":43,"tag":647,"props":2345,"children":2346},{},[2347],{"type":49,"value":2348},"        logger.LogWarning(exception, \"Handled API exception: {Title}\", title);\n",{"type":43,"tag":647,"props":2350,"children":2352},{"class":649,"line":2351},23,[2353],{"type":43,"tag":647,"props":2354,"children":2355},{"emptyLinePlaceholder":933},[2356],{"type":49,"value":936},{"type":43,"tag":647,"props":2358,"children":2360},{"class":649,"line":2359},24,[2361],{"type":43,"tag":647,"props":2362,"children":2363},{},[2364],{"type":49,"value":2365},"        httpContext.Response.StatusCode = statusCode;\n",{"type":43,"tag":647,"props":2367,"children":2369},{"class":649,"line":2368},25,[2370],{"type":43,"tag":647,"props":2371,"children":2372},{},[2373],{"type":49,"value":2374},"        await httpContext.Response.WriteAsJsonAsync(new ProblemDetails\n",{"type":43,"tag":647,"props":2376,"children":2378},{"class":649,"line":2377},26,[2379],{"type":43,"tag":647,"props":2380,"children":2381},{},[2382],{"type":49,"value":2248},{"type":43,"tag":647,"props":2384,"children":2386},{"class":649,"line":2385},27,[2387],{"type":43,"tag":647,"props":2388,"children":2389},{},[2390],{"type":49,"value":2391},"            Status = statusCode,\n",{"type":43,"tag":647,"props":2393,"children":2395},{"class":649,"line":2394},28,[2396],{"type":43,"tag":647,"props":2397,"children":2398},{},[2399],{"type":49,"value":2400},"            Title = title,\n",{"type":43,"tag":647,"props":2402,"children":2404},{"class":649,"line":2403},29,[2405],{"type":43,"tag":647,"props":2406,"children":2407},{},[2408],{"type":49,"value":2409},"            \u002F\u002F Do not use exception.Message here — it may leak sensitive internal details.\n",{"type":43,"tag":647,"props":2411,"children":2413},{"class":649,"line":2412},30,[2414],{"type":43,"tag":647,"props":2415,"children":2416},{},[2417],{"type":49,"value":2418},"            \u002F\u002F Use a safe, user-facing message instead.\n",{"type":43,"tag":647,"props":2420,"children":2422},{"class":649,"line":2421},31,[2423],{"type":43,"tag":647,"props":2424,"children":2425},{},[2426],{"type":49,"value":2427},"            Detail = title,\n",{"type":43,"tag":647,"props":2429,"children":2431},{"class":649,"line":2430},32,[2432],{"type":43,"tag":647,"props":2433,"children":2434},{},[2435],{"type":49,"value":2436},"            Instance = httpContext.Request.Path\n",{"type":43,"tag":647,"props":2438,"children":2440},{"class":649,"line":2439},33,[2441],{"type":43,"tag":647,"props":2442,"children":2443},{},[2444],{"type":49,"value":2445},"        }, cancellationToken);\n",{"type":43,"tag":647,"props":2447,"children":2449},{"class":649,"line":2448},34,[2450],{"type":43,"tag":647,"props":2451,"children":2452},{"emptyLinePlaceholder":933},[2453],{"type":49,"value":936},{"type":43,"tag":647,"props":2455,"children":2457},{"class":649,"line":2456},35,[2458],{"type":43,"tag":647,"props":2459,"children":2460},{},[2461],{"type":49,"value":2462},"        return true;\n",{"type":43,"tag":647,"props":2464,"children":2466},{"class":649,"line":2465},36,[2467],{"type":43,"tag":647,"props":2468,"children":2469},{},[2470],{"type":49,"value":2471},"    }\n",{"type":43,"tag":647,"props":2473,"children":2475},{"class":649,"line":2474},37,[2476],{"type":43,"tag":647,"props":2477,"children":2478},{},[2479],{"type":49,"value":975},{"type":43,"tag":52,"props":2481,"children":2482},{},[2483],{"type":49,"value":2484},"Register it:",{"type":43,"tag":636,"props":2486,"children":2488},{"className":638,"code":2487,"language":640,"meta":641,"style":641},"builder.Services.AddExceptionHandler\u003CApiExceptionHandler>();\nbuilder.Services.AddProblemDetails();\n\napp.UseExceptionHandler();\n",[2489],{"type":43,"tag":95,"props":2490,"children":2491},{"__ignoreMap":641},[2492,2500,2507,2514],{"type":43,"tag":647,"props":2493,"children":2494},{"class":649,"line":650},[2495],{"type":43,"tag":647,"props":2496,"children":2497},{},[2498],{"type":49,"value":2499},"builder.Services.AddExceptionHandler\u003CApiExceptionHandler>();\n",{"type":43,"tag":647,"props":2501,"children":2502},{"class":649,"line":659},[2503],{"type":43,"tag":647,"props":2504,"children":2505},{},[2506],{"type":49,"value":2120},{"type":43,"tag":647,"props":2508,"children":2509},{"class":649,"line":668},[2510],{"type":43,"tag":647,"props":2511,"children":2512},{"emptyLinePlaceholder":933},[2513],{"type":49,"value":936},{"type":43,"tag":647,"props":2515,"children":2516},{"class":649,"line":677},[2517],{"type":43,"tag":647,"props":2518,"children":2519},{},[2520],{"type":49,"value":2135},{"type":43,"tag":52,"props":2522,"children":2523},{},[2524,2529,2531,2537],{"type":43,"tag":324,"props":2525,"children":2526},{},[2527],{"type":49,"value":2528},"File placement:",{"type":49,"value":2530}," Always place exception handler classes in a ",{"type":43,"tag":95,"props":2532,"children":2534},{"className":2533},[],[2535],{"type":49,"value":2536},"Middleware\u002F",{"type":49,"value":2538},"\nfolder to maintain consistent project organization. Do not place them at the\nproject root.",{"type":43,"tag":259,"props":2540,"children":2542},{"id":2541},"step-6-use-a-service-layer",[2543],{"type":49,"value":2544},"Step 6: Use a service layer",{"type":43,"tag":52,"props":2546,"children":2547},{},[2548],{"type":49,"value":2549},"Do not inject data stores directly into controllers or endpoint handlers.\nCreate a service interface and a sealed implementation class that owns the\ndata access logic and mapping between entities and request\u002Fresponse types.",{"type":43,"tag":52,"props":2551,"children":2552},{},[2553],{"type":49,"value":2554},"Always define an interface for every service — this enables unit testing with\nmocks and follows the Dependency Inversion Principle:",{"type":43,"tag":636,"props":2556,"children":2558},{"className":638,"code":2557,"language":640,"meta":641,"style":641},"\u002F\u002F Services\u002FIProductService.cs\npublic interface IProductService\n{\n    Task\u003CIReadOnlyList\u003CProductResponse>> GetAllAsync(CancellationToken ct);\n    Task\u003CProductResponse?> GetByIdAsync(int id, CancellationToken ct);\n    Task\u003CProductResponse> CreateAsync(CreateProductRequest request, CancellationToken ct);\n}\n\n\u002F\u002F Services\u002FProductService.cs\npublic sealed class ProductService(...) : IProductService\n{\n    \u002F\u002F Data access logic, entity-to-DTO mapping\n}\n",[2559],{"type":43,"tag":95,"props":2560,"children":2561},{"__ignoreMap":641},[2562,2570,2578,2585,2593,2601,2609,2616,2623,2631,2639,2646,2654],{"type":43,"tag":647,"props":2563,"children":2564},{"class":649,"line":650},[2565],{"type":43,"tag":647,"props":2566,"children":2567},{},[2568],{"type":49,"value":2569},"\u002F\u002F Services\u002FIProductService.cs\n",{"type":43,"tag":647,"props":2571,"children":2572},{"class":649,"line":659},[2573],{"type":43,"tag":647,"props":2574,"children":2575},{},[2576],{"type":49,"value":2577},"public interface IProductService\n",{"type":43,"tag":647,"props":2579,"children":2580},{"class":649,"line":668},[2581],{"type":43,"tag":647,"props":2582,"children":2583},{},[2584],{"type":49,"value":683},{"type":43,"tag":647,"props":2586,"children":2587},{"class":649,"line":677},[2588],{"type":43,"tag":647,"props":2589,"children":2590},{},[2591],{"type":49,"value":2592},"    Task\u003CIReadOnlyList\u003CProductResponse>> GetAllAsync(CancellationToken ct);\n",{"type":43,"tag":647,"props":2594,"children":2595},{"class":649,"line":686},[2596],{"type":43,"tag":647,"props":2597,"children":2598},{},[2599],{"type":49,"value":2600},"    Task\u003CProductResponse?> GetByIdAsync(int id, CancellationToken ct);\n",{"type":43,"tag":647,"props":2602,"children":2603},{"class":649,"line":695},[2604],{"type":43,"tag":647,"props":2605,"children":2606},{},[2607],{"type":49,"value":2608},"    Task\u003CProductResponse> CreateAsync(CreateProductRequest request, CancellationToken ct);\n",{"type":43,"tag":647,"props":2610,"children":2611},{"class":649,"line":704},[2612],{"type":43,"tag":647,"props":2613,"children":2614},{},[2615],{"type":49,"value":975},{"type":43,"tag":647,"props":2617,"children":2618},{"class":649,"line":713},[2619],{"type":43,"tag":647,"props":2620,"children":2621},{"emptyLinePlaceholder":933},[2622],{"type":49,"value":936},{"type":43,"tag":647,"props":2624,"children":2625},{"class":649,"line":722},[2626],{"type":43,"tag":647,"props":2627,"children":2628},{},[2629],{"type":49,"value":2630},"\u002F\u002F Services\u002FProductService.cs\n",{"type":43,"tag":647,"props":2632,"children":2633},{"class":649,"line":731},[2634],{"type":43,"tag":647,"props":2635,"children":2636},{},[2637],{"type":49,"value":2638},"public sealed class ProductService(...) : IProductService\n",{"type":43,"tag":647,"props":2640,"children":2641},{"class":649,"line":740},[2642],{"type":43,"tag":647,"props":2643,"children":2644},{},[2645],{"type":49,"value":683},{"type":43,"tag":647,"props":2647,"children":2648},{"class":649,"line":749},[2649],{"type":43,"tag":647,"props":2650,"children":2651},{},[2652],{"type":49,"value":2653},"    \u002F\u002F Data access logic, entity-to-DTO mapping\n",{"type":43,"tag":647,"props":2655,"children":2656},{"class":649,"line":758},[2657],{"type":43,"tag":647,"props":2658,"children":2659},{},[2660],{"type":49,"value":975},{"type":43,"tag":52,"props":2662,"children":2663},{},[2664],{"type":49,"value":2665},"Register with the interface, not the concrete type:",{"type":43,"tag":636,"props":2667,"children":2669},{"className":638,"code":2668,"language":640,"meta":641,"style":641},"\u002F\u002F In Program.cs\nbuilder.Services.AddScoped\u003CIProductService, ProductService>();\n",[2670],{"type":43,"tag":95,"props":2671,"children":2672},{"__ignoreMap":641},[2673,2681],{"type":43,"tag":647,"props":2674,"children":2675},{"class":649,"line":650},[2676],{"type":43,"tag":647,"props":2677,"children":2678},{},[2679],{"type":49,"value":2680},"\u002F\u002F In Program.cs\n",{"type":43,"tag":647,"props":2682,"children":2683},{"class":649,"line":659},[2684],{"type":43,"tag":647,"props":2685,"children":2686},{},[2687],{"type":49,"value":2688},"builder.Services.AddScoped\u003CIProductService, ProductService>();\n",{"type":43,"tag":52,"props":2690,"children":2691},{},[2692,2694,2700,2702,2707],{"type":49,"value":2693},"For EF Core data access patterns (migrations, Fluent API configuration,\n",{"type":43,"tag":95,"props":2695,"children":2697},{"className":2696},[],[2698],{"type":49,"value":2699},"AsNoTracking",{"type":49,"value":2701},", seed data), see the ",{"type":43,"tag":95,"props":2703,"children":2705},{"className":2704},[],[2706],{"type":49,"value":137},{"type":49,"value":2708}," skill.",{"type":43,"tag":259,"props":2710,"children":2712},{"id":2711},"step-7-create-a-http-test-file",[2713],{"type":49,"value":2714},"Step 7: Create a .http test file",{"type":43,"tag":52,"props":2716,"children":2717},{},[2718,2720,2725],{"type":49,"value":2719},"After implementing endpoints, create a ",{"type":43,"tag":95,"props":2721,"children":2723},{"className":2722},[],[2724],{"type":49,"value":100},{"type":49,"value":2726}," file in the project root that\ndemonstrates how to call every new endpoint. This serves as living\ndocumentation and a quick manual test harness.",{"type":43,"tag":636,"props":2728,"children":2732},{"className":2729,"code":2730,"language":2731,"meta":641,"style":641},"language-http shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","@baseUrl = http:\u002F\u002Flocalhost:5000\n\n### Get all products\nGET {{baseUrl}}\u002Fapi\u002Fproducts\n\n### Get product by ID\nGET {{baseUrl}}\u002Fapi\u002Fproducts\u002F1\n\n### Create a product\nPOST {{baseUrl}}\u002Fapi\u002Fproducts\nContent-Type: application\u002Fjson\n\n{\n  \"name\": \"Wireless Mouse\",\n  \"price\": 29.99,\n  \"category\": \"Electronics\"\n}\n\n### Delete a product\nDELETE {{baseUrl}}\u002Fapi\u002Fproducts\u002F1\n","http",[2733],{"type":43,"tag":95,"props":2734,"children":2735},{"__ignoreMap":641},[2736,2744,2751,2759,2767,2774,2782,2790,2797,2805,2813,2821,2828,2835,2843,2851,2859,2866,2873,2881],{"type":43,"tag":647,"props":2737,"children":2738},{"class":649,"line":650},[2739],{"type":43,"tag":647,"props":2740,"children":2741},{},[2742],{"type":49,"value":2743},"@baseUrl = http:\u002F\u002Flocalhost:5000\n",{"type":43,"tag":647,"props":2745,"children":2746},{"class":649,"line":659},[2747],{"type":43,"tag":647,"props":2748,"children":2749},{"emptyLinePlaceholder":933},[2750],{"type":49,"value":936},{"type":43,"tag":647,"props":2752,"children":2753},{"class":649,"line":668},[2754],{"type":43,"tag":647,"props":2755,"children":2756},{},[2757],{"type":49,"value":2758},"### Get all products\n",{"type":43,"tag":647,"props":2760,"children":2761},{"class":649,"line":677},[2762],{"type":43,"tag":647,"props":2763,"children":2764},{},[2765],{"type":49,"value":2766},"GET {{baseUrl}}\u002Fapi\u002Fproducts\n",{"type":43,"tag":647,"props":2768,"children":2769},{"class":649,"line":686},[2770],{"type":43,"tag":647,"props":2771,"children":2772},{"emptyLinePlaceholder":933},[2773],{"type":49,"value":936},{"type":43,"tag":647,"props":2775,"children":2776},{"class":649,"line":695},[2777],{"type":43,"tag":647,"props":2778,"children":2779},{},[2780],{"type":49,"value":2781},"### Get product by ID\n",{"type":43,"tag":647,"props":2783,"children":2784},{"class":649,"line":704},[2785],{"type":43,"tag":647,"props":2786,"children":2787},{},[2788],{"type":49,"value":2789},"GET {{baseUrl}}\u002Fapi\u002Fproducts\u002F1\n",{"type":43,"tag":647,"props":2791,"children":2792},{"class":649,"line":713},[2793],{"type":43,"tag":647,"props":2794,"children":2795},{"emptyLinePlaceholder":933},[2796],{"type":49,"value":936},{"type":43,"tag":647,"props":2798,"children":2799},{"class":649,"line":722},[2800],{"type":43,"tag":647,"props":2801,"children":2802},{},[2803],{"type":49,"value":2804},"### Create a product\n",{"type":43,"tag":647,"props":2806,"children":2807},{"class":649,"line":731},[2808],{"type":43,"tag":647,"props":2809,"children":2810},{},[2811],{"type":49,"value":2812},"POST {{baseUrl}}\u002Fapi\u002Fproducts\n",{"type":43,"tag":647,"props":2814,"children":2815},{"class":649,"line":740},[2816],{"type":43,"tag":647,"props":2817,"children":2818},{},[2819],{"type":49,"value":2820},"Content-Type: application\u002Fjson\n",{"type":43,"tag":647,"props":2822,"children":2823},{"class":649,"line":749},[2824],{"type":43,"tag":647,"props":2825,"children":2826},{"emptyLinePlaceholder":933},[2827],{"type":49,"value":936},{"type":43,"tag":647,"props":2829,"children":2830},{"class":649,"line":758},[2831],{"type":43,"tag":647,"props":2832,"children":2833},{},[2834],{"type":49,"value":683},{"type":43,"tag":647,"props":2836,"children":2837},{"class":649,"line":1814},[2838],{"type":43,"tag":647,"props":2839,"children":2840},{},[2841],{"type":49,"value":2842},"  \"name\": \"Wireless Mouse\",\n",{"type":43,"tag":647,"props":2844,"children":2845},{"class":649,"line":1823},[2846],{"type":43,"tag":647,"props":2847,"children":2848},{},[2849],{"type":49,"value":2850},"  \"price\": 29.99,\n",{"type":43,"tag":647,"props":2852,"children":2853},{"class":649,"line":1832},[2854],{"type":43,"tag":647,"props":2855,"children":2856},{},[2857],{"type":49,"value":2858},"  \"category\": \"Electronics\"\n",{"type":43,"tag":647,"props":2860,"children":2861},{"class":649,"line":2298},[2862],{"type":43,"tag":647,"props":2863,"children":2864},{},[2865],{"type":49,"value":975},{"type":43,"tag":647,"props":2867,"children":2868},{"class":649,"line":2307},[2869],{"type":43,"tag":647,"props":2870,"children":2871},{"emptyLinePlaceholder":933},[2872],{"type":49,"value":936},{"type":43,"tag":647,"props":2874,"children":2875},{"class":649,"line":2316},[2876],{"type":43,"tag":647,"props":2877,"children":2878},{},[2879],{"type":49,"value":2880},"### Delete a product\n",{"type":43,"tag":647,"props":2882,"children":2883},{"class":649,"line":2324},[2884],{"type":43,"tag":647,"props":2885,"children":2886},{},[2887],{"type":49,"value":2888},"DELETE {{baseUrl}}\u002Fapi\u002Fproducts\u002F1\n",{"type":43,"tag":52,"props":2890,"children":2891},{},[2892,2894,2900],{"type":49,"value":2893},"Include at least one request per endpoint with realistic bodies. Show error\npaths (e.g., non-existent IDs). Match the port to ",{"type":43,"tag":95,"props":2895,"children":2897},{"className":2896},[],[2898],{"type":49,"value":2899},"launchSettings.json",{"type":49,"value":292},{"type":43,"tag":259,"props":2902,"children":2904},{"id":2903},"step-8-build-and-verify",[2905],{"type":49,"value":2906},"Step 8: Build and verify",{"type":43,"tag":271,"props":2908,"children":2909},{},[2910,2923,2935],{"type":43,"tag":74,"props":2911,"children":2912},{},[2913,2915,2921],{"type":49,"value":2914},"Run ",{"type":43,"tag":95,"props":2916,"children":2918},{"className":2917},[],[2919],{"type":49,"value":2920},"dotnet build",{"type":49,"value":2922}," — confirm zero errors and zero warnings.",{"type":43,"tag":74,"props":2924,"children":2925},{},[2926,2928,2934],{"type":49,"value":2927},"Start the app and verify the OpenAPI document loads (default: ",{"type":43,"tag":95,"props":2929,"children":2931},{"className":2930},[],[2932],{"type":49,"value":2933},"\u002Fopenapi\u002Fv1.json",{"type":49,"value":995},{"type":43,"tag":74,"props":2936,"children":2937},{},[2938,2940,2945],{"type":49,"value":2939},"Run the requests in the ",{"type":43,"tag":95,"props":2941,"children":2943},{"className":2942},[],[2944],{"type":49,"value":100},{"type":49,"value":2946}," file and confirm correct status codes.",{"type":43,"tag":58,"props":2948,"children":2950},{"id":2949},"validation",[2951],{"type":49,"value":2952},"Validation",{"type":43,"tag":70,"props":2954,"children":2957},{"className":2955},[2956],"contains-task-list",[2958,2970,2992,3006,3020,3036,3045,3054,3063,3072,3081,3097,3118,3134,3149,3165,3188,3197],{"type":43,"tag":74,"props":2959,"children":2962},{"className":2960},[2961],"task-list-item",[2963,2968],{"type":43,"tag":2964,"props":2965,"children":2967},"input",{"disabled":933,"type":2966},"checkbox",[],{"type":49,"value":2969}," All endpoints return correct HTTP status codes per the table in Step 3",{"type":43,"tag":74,"props":2971,"children":2973},{"className":2972},[2961],[2974,2977,2979,2984,2986,2991],{"type":43,"tag":2964,"props":2975,"children":2976},{"disabled":933,"type":2966},[],{"type":49,"value":2978}," POST endpoints return ",{"type":43,"tag":95,"props":2980,"children":2982},{"className":2981},[],[2983],{"type":49,"value":1520},{"type":49,"value":2985}," with a ",{"type":43,"tag":95,"props":2987,"children":2989},{"className":2988},[],[2990],{"type":49,"value":1528},{"type":49,"value":1530},{"type":43,"tag":74,"props":2993,"children":2995},{"className":2994},[2961],[2996,2999,3001],{"type":43,"tag":2964,"props":2997,"children":2998},{"disabled":933,"type":2966},[],{"type":49,"value":3000}," DELETE endpoints return ",{"type":43,"tag":95,"props":3002,"children":3004},{"className":3003},[],[3005],{"type":49,"value":1622},{"type":43,"tag":74,"props":3007,"children":3009},{"className":3008},[2961],[3010,3013,3015],{"type":43,"tag":2964,"props":3011,"children":3012},{"disabled":933,"type":2966},[],{"type":49,"value":3014}," Every endpoint signature includes ",{"type":43,"tag":95,"props":3016,"children":3018},{"className":3017},[],[3019],{"type":49,"value":1694},{"type":43,"tag":74,"props":3021,"children":3023},{"className":3022},[2961],[3024,3027,3029,3034],{"type":43,"tag":2964,"props":3025,"children":3026},{"disabled":933,"type":2966},[],{"type":49,"value":3028}," ",{"type":43,"tag":95,"props":3030,"children":3032},{"className":3031},[],[3033],{"type":49,"value":1694},{"type":49,"value":3035}," is forwarded to all downstream async calls",{"type":43,"tag":74,"props":3037,"children":3039},{"className":3038},[2961],[3040,3043],{"type":43,"tag":2964,"props":3041,"children":3042},{"disabled":933,"type":2966},[],{"type":49,"value":3044}," OpenAPI document is generated and includes all new endpoints",{"type":43,"tag":74,"props":3046,"children":3048},{"className":3047},[2961],[3049,3052],{"type":43,"tag":2964,"props":3050,"children":3051},{"disabled":933,"type":2966},[],{"type":49,"value":3053}," Endpoints have summary\u002Fdescription metadata for OpenAPI",{"type":43,"tag":74,"props":3055,"children":3057},{"className":3056},[2961],[3058,3061],{"type":43,"tag":2964,"props":3059,"children":3060},{"disabled":933,"type":2966},[],{"type":49,"value":3062}," Enum values appear as strings in JSON responses and OpenAPI schemas (unless user explicitly requested integer serialization)",{"type":43,"tag":74,"props":3064,"children":3066},{"className":3065},[2961],[3067,3070],{"type":43,"tag":2964,"props":3068,"children":3069},{"disabled":933,"type":2966},[],{"type":49,"value":3071}," Error responses use RFC 7807 Problem Details format",{"type":43,"tag":74,"props":3073,"children":3075},{"className":3074},[2961],[3076,3079],{"type":43,"tag":2964,"props":3077,"children":3078},{"disabled":933,"type":2966},[],{"type":49,"value":3080}," Domain entities are not exposed directly in API request\u002Fresponse bodies",{"type":43,"tag":74,"props":3082,"children":3084},{"className":3083},[2961],[3085,3088,3090,3095],{"type":43,"tag":2964,"props":3086,"children":3087},{"disabled":933,"type":2966},[],{"type":49,"value":3089}," All API-exposed DTOs have ",{"type":43,"tag":95,"props":3091,"children":3093},{"className":3092},[],[3094],{"type":49,"value":548},{"type":49,"value":3096}," XML doc comments",{"type":43,"tag":74,"props":3098,"children":3100},{"className":3099},[2961],[3101,3104,3106,3111,3113],{"type":43,"tag":2964,"props":3102,"children":3103},{"disabled":933,"type":2966},[],{"type":49,"value":3105}," Date and time properties use ",{"type":43,"tag":95,"props":3107,"children":3109},{"className":3108},[],[3110],{"type":49,"value":577},{"type":49,"value":3112},", not ",{"type":43,"tag":95,"props":3114,"children":3116},{"className":3115},[],[3117],{"type":49,"value":594},{"type":43,"tag":74,"props":3119,"children":3121},{"className":3120},[2961],[3122,3125,3127,3132],{"type":43,"tag":2964,"props":3123,"children":3124},{"disabled":933,"type":2966},[],{"type":49,"value":3126}," A ",{"type":43,"tag":95,"props":3128,"children":3130},{"className":3129},[],[3131],{"type":49,"value":100},{"type":49,"value":3133}," file exists with a request for every new endpoint",{"type":43,"tag":74,"props":3135,"children":3137},{"className":3136},[2961],[3138,3141,3142,3147],{"type":43,"tag":2964,"props":3139,"children":3140},{"disabled":933,"type":2966},[],{"type":49,"value":3028},{"type":43,"tag":95,"props":3143,"children":3145},{"className":3144},[],[3146],{"type":49,"value":2920},{"type":49,"value":3148}," passes with zero errors and zero warnings",{"type":43,"tag":74,"props":3150,"children":3152},{"className":3151},[2961],[3153,3156,3158,3163],{"type":43,"tag":2964,"props":3154,"children":3155},{"disabled":933,"type":2966},[],{"type":49,"value":3157}," All DTOs are ",{"type":43,"tag":95,"props":3159,"children":3161},{"className":3160},[],[3162],{"type":49,"value":383},{"type":49,"value":3164}," types (not mutable classes)",{"type":43,"tag":74,"props":3166,"children":3168},{"className":3167},[2961],[3169,3172,3174,3179,3181,3186],{"type":43,"tag":2964,"props":3170,"children":3171},{"disabled":933,"type":2966},[],{"type":49,"value":3173}," Minimal API handlers use ",{"type":43,"tag":95,"props":3175,"children":3177},{"className":3176},[],[3178],{"type":49,"value":1235},{"type":49,"value":3180}," with explicit ",{"type":43,"tag":95,"props":3182,"children":3184},{"className":3183},[],[3185],{"type":49,"value":1297},{"type":49,"value":3187}," return types",{"type":43,"tag":74,"props":3189,"children":3191},{"className":3190},[2961],[3192,3195],{"type":43,"tag":2964,"props":3193,"children":3194},{"disabled":933,"type":2966},[],{"type":49,"value":3196}," Every service has a corresponding interface registered in DI",{"type":43,"tag":74,"props":3198,"children":3200},{"className":3199},[2961],[3201,3204,3206,3211],{"type":43,"tag":2964,"props":3202,"children":3203},{"disabled":933,"type":2966},[],{"type":49,"value":3205}," Exception handlers are placed in the ",{"type":43,"tag":95,"props":3207,"children":3209},{"className":3208},[],[3210],{"type":49,"value":2536},{"type":49,"value":3212}," folder",{"type":43,"tag":58,"props":3214,"children":3216},{"id":3215},"common-pitfalls",[3217],{"type":49,"value":3218},"Common Pitfalls",{"type":43,"tag":397,"props":3220,"children":3221},{},[3222,3238],{"type":43,"tag":401,"props":3223,"children":3224},{},[3225],{"type":43,"tag":405,"props":3226,"children":3227},{},[3228,3233],{"type":43,"tag":409,"props":3229,"children":3230},{},[3231],{"type":49,"value":3232},"Pitfall",{"type":43,"tag":409,"props":3234,"children":3235},{},[3236],{"type":49,"value":3237},"Solution",{"type":43,"tag":425,"props":3239,"children":3240},{},[3241,3261,3279,3312,3354,3367,3380,3424,3450,3478,3526,3546,3572],{"type":43,"tag":405,"props":3242,"children":3243},{},[3244,3249],{"type":43,"tag":432,"props":3245,"children":3246},{},[3247],{"type":49,"value":3248},"Exposing domain entities as API responses",{"type":43,"tag":432,"props":3250,"children":3251},{},[3252,3254,3259],{"type":49,"value":3253},"Create separate ",{"type":43,"tag":95,"props":3255,"children":3257},{"className":3256},[],[3258],{"type":49,"value":383},{"type":49,"value":3260}," request\u002Fresponse types. Entities leak navigation properties and internal fields.",{"type":43,"tag":405,"props":3262,"children":3263},{},[3264,3274],{"type":43,"tag":432,"props":3265,"children":3266},{},[3267,3269],{"type":49,"value":3268},"Forgetting ",{"type":43,"tag":95,"props":3270,"children":3272},{"className":3271},[],[3273],{"type":49,"value":1694},{"type":43,"tag":432,"props":3275,"children":3276},{},[3277],{"type":49,"value":3278},"Add to every endpoint and forward through the entire async call chain.",{"type":43,"tag":405,"props":3280,"children":3281},{},[3282,3294],{"type":43,"tag":432,"props":3283,"children":3284},{},[3285,3287,3292],{"type":49,"value":3286},"Returning ",{"type":43,"tag":95,"props":3288,"children":3290},{"className":3289},[],[3291],{"type":49,"value":1473},{"type":49,"value":3293}," from POST create",{"type":43,"tag":432,"props":3295,"children":3296},{},[3297,3299,3304,3305,3310],{"type":49,"value":3298},"Return ",{"type":43,"tag":95,"props":3300,"children":3302},{"className":3301},[],[3303],{"type":49,"value":1520},{"type":49,"value":2985},{"type":43,"tag":95,"props":3306,"children":3308},{"className":3307},[],[3309],{"type":49,"value":1528},{"type":49,"value":3311}," header.",{"type":43,"tag":405,"props":3313,"children":3314},{},[3315,3320],{"type":43,"tag":432,"props":3316,"children":3317},{},[3318],{"type":49,"value":3319},"Missing OpenAPI metadata",{"type":43,"tag":432,"props":3321,"children":3322},{},[3323,3325,3331,3332,3338,3339,3345,3346,3352],{"type":49,"value":3324},"Chain ",{"type":43,"tag":95,"props":3326,"children":3328},{"className":3327},[],[3329],{"type":49,"value":3330},".WithName()",{"type":49,"value":213},{"type":43,"tag":95,"props":3333,"children":3335},{"className":3334},[],[3336],{"type":49,"value":3337},".WithSummary()",{"type":49,"value":213},{"type":43,"tag":95,"props":3340,"children":3342},{"className":3341},[],[3343],{"type":49,"value":3344},".WithDescription()",{"type":49,"value":213},{"type":43,"tag":95,"props":3347,"children":3349},{"className":3348},[],[3350],{"type":49,"value":3351},".Produces\u003CT>()",{"type":49,"value":3353}," on every endpoint.",{"type":43,"tag":405,"props":3355,"children":3356},{},[3357,3362],{"type":43,"tag":432,"props":3358,"children":3359},{},[3360],{"type":49,"value":3361},"Injecting data stores directly into endpoints",{"type":43,"tag":432,"props":3363,"children":3364},{},[3365],{"type":49,"value":3366},"Use a service layer with an interface for separation and testability.",{"type":43,"tag":405,"props":3368,"children":3369},{},[3370,3375],{"type":43,"tag":432,"props":3371,"children":3372},{},[3373],{"type":49,"value":3374},"Mixing controller and minimal API styles",{"type":43,"tag":432,"props":3376,"children":3377},{},[3378],{"type":49,"value":3379},"Pick one per project and be consistent.",{"type":43,"tag":405,"props":3381,"children":3382},{},[3383,3393],{"type":43,"tag":432,"props":3384,"children":3385},{},[3386,3391],{"type":43,"tag":95,"props":3387,"children":3389},{"className":3388},[],[3390],{"type":49,"value":1235},{"type":49,"value":3392}," in ternary without explicit return type",{"type":43,"tag":432,"props":3394,"children":3395},{},[3396,3401,3402,3407,3409,3415,3417,3422],{"type":43,"tag":95,"props":3397,"children":3399},{"className":3398},[],[3400],{"type":49,"value":1351},{"type":49,"value":1337},{"type":43,"tag":95,"props":3403,"children":3405},{"className":3404},[],[3406],{"type":49,"value":1289},{"type":49,"value":3408}," have no common base — annotate with ",{"type":43,"tag":95,"props":3410,"children":3412},{"className":3411},[],[3413],{"type":49,"value":3414},"Task\u003CResults\u003COk\u003CT>, NotFound>>",{"type":49,"value":3416}," or fall back to ",{"type":43,"tag":95,"props":3418,"children":3420},{"className":3419},[],[3421],{"type":49,"value":1254},{"type":49,"value":3423}," factory.",{"type":43,"tag":405,"props":3425,"children":3426},{},[3427,3432],{"type":43,"tag":432,"props":3428,"children":3429},{},[3430],{"type":49,"value":3431},"Using mutable classes for DTOs",{"type":43,"tag":432,"props":3433,"children":3434},{},[3435,3436,3441,3443,3448],{"type":49,"value":377},{"type":43,"tag":95,"props":3437,"children":3439},{"className":3438},[],[3440],{"type":49,"value":383},{"type":49,"value":3442}," with positional syntax (responses) or ",{"type":43,"tag":95,"props":3444,"children":3446},{"className":3445},[],[3447],{"type":49,"value":879},{"type":49,"value":3449}," properties (requests).",{"type":43,"tag":405,"props":3451,"children":3452},{},[3453,3458],{"type":43,"tag":432,"props":3454,"children":3455},{},[3456],{"type":49,"value":3457},"Registering services without interfaces",{"type":43,"tag":432,"props":3459,"children":3460},{},[3461,3463,3469,3471,3477],{"type":49,"value":3462},"Define ",{"type":43,"tag":95,"props":3464,"children":3466},{"className":3465},[],[3467],{"type":49,"value":3468},"IService",{"type":49,"value":3470}," and register with ",{"type":43,"tag":95,"props":3472,"children":3474},{"className":3473},[],[3475],{"type":49,"value":3476},"AddScoped\u003CIService, Service>()",{"type":49,"value":292},{"type":43,"tag":405,"props":3479,"children":3480},{},[3481,3493],{"type":43,"tag":432,"props":3482,"children":3483},{},[3484,3486,3491],{"type":49,"value":3485},"Adding any ",{"type":43,"tag":95,"props":3487,"children":3489},{"className":3488},[],[3490],{"type":49,"value":1888},{"type":49,"value":3492}," package to new .NET 9+ projects",{"type":43,"tag":432,"props":3494,"children":3495},{},[3496,3498,3504,3505,3511,3513,3518,3519,3524],{"type":49,"value":3497},"Use built-in ",{"type":43,"tag":95,"props":3499,"children":3501},{"className":3500},[],[3502],{"type":49,"value":3503},"AddOpenApi()",{"type":49,"value":1866},{"type":43,"tag":95,"props":3506,"children":3508},{"className":3507},[],[3509],{"type":49,"value":3510},"MapOpenApi()",{"type":49,"value":3512},". Do not add ",{"type":43,"tag":95,"props":3514,"children":3516},{"className":3515},[],[3517],{"type":49,"value":1898},{"type":49,"value":213},{"type":43,"tag":95,"props":3520,"children":3522},{"className":3521},[],[3523],{"type":49,"value":1905},{"type":49,"value":3525},", or any other Swashbuckle package.",{"type":43,"tag":405,"props":3527,"children":3528},{},[3529,3534],{"type":43,"tag":432,"props":3530,"children":3531},{},[3532],{"type":49,"value":3533},"Missing XML doc comments on DTOs",{"type":43,"tag":432,"props":3535,"children":3536},{},[3537,3539,3544],{"type":49,"value":3538},"Add ",{"type":43,"tag":95,"props":3540,"children":3542},{"className":3541},[],[3543],{"type":49,"value":548},{"type":49,"value":3545}," XML doc comments to every request and response type. These flow into the generated OpenAPI spec automatically.",{"type":43,"tag":405,"props":3547,"children":3548},{},[3549,3561],{"type":43,"tag":432,"props":3550,"children":3551},{},[3552,3554,3559],{"type":49,"value":3553},"Using ",{"type":43,"tag":95,"props":3555,"children":3557},{"className":3556},[],[3558],{"type":49,"value":594},{"type":49,"value":3560}," for date\u002Ftime properties",{"type":43,"tag":432,"props":3562,"children":3563},{},[3564,3565,3570],{"type":49,"value":377},{"type":43,"tag":95,"props":3566,"children":3568},{"className":3567},[],[3569],{"type":49,"value":577},{"type":49,"value":3571}," instead — it preserves UTC offset, avoids timezone ambiguity, and serializes correctly in JSON.",{"type":43,"tag":405,"props":3573,"children":3574},{},[3575,3580],{"type":43,"tag":432,"props":3576,"children":3577},{},[3578],{"type":49,"value":3579},"Serializing enums as integers",{"type":43,"tag":432,"props":3581,"children":3582},{},[3583,3585,3590],{"type":49,"value":3584},"Configure ",{"type":43,"tag":95,"props":3586,"children":3588},{"className":3587},[],[3589],{"type":49,"value":780},{"type":49,"value":3591}," so enums serialize as strings by default. Only use integer serialization if the user explicitly requests it.",{"type":43,"tag":58,"props":3593,"children":3595},{"id":3594},"more-info",[3596],{"type":49,"value":3597},"More Info",{"type":43,"tag":70,"props":3599,"children":3600},{},[3601,3613,3624,3635,3647,3659],{"type":43,"tag":74,"props":3602,"children":3603},{},[3604,3611],{"type":43,"tag":557,"props":3605,"children":3608},{"href":3606,"rel":3607},"https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Fweb-api\u002F",[561],[3609],{"type":49,"value":3610},"ASP.NET Core Web API overview",{"type":49,"value":3612}," — fundamental concepts for building Web APIs",{"type":43,"tag":74,"props":3614,"children":3615},{},[3616,3622],{"type":43,"tag":557,"props":3617,"children":3619},{"href":1921,"rel":3618},[561],[3620],{"type":49,"value":3621},"OpenAPI in ASP.NET Core",{"type":49,"value":3623}," — built-in OpenAPI support in .NET 9+",{"type":43,"tag":74,"props":3625,"children":3626},{},[3627,3633],{"type":43,"tag":557,"props":3628,"children":3630},{"href":559,"rel":3629},[561],[3631],{"type":49,"value":3632},"OpenAPI from XML comments",{"type":49,"value":3634}," — how XML doc comments flow into the OpenAPI spec",{"type":43,"tag":74,"props":3636,"children":3637},{},[3638,3645],{"type":43,"tag":557,"props":3639,"children":3642},{"href":3640,"rel":3641},"https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Ffundamentals\u002Fminimal-apis\u002Foverview",[561],[3643],{"type":49,"value":3644},"Minimal APIs overview",{"type":49,"value":3646}," — routing, parameter binding, and response types",{"type":43,"tag":74,"props":3648,"children":3649},{},[3650,3657],{"type":43,"tag":557,"props":3651,"children":3654},{"href":3652,"rel":3653},"https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Faspnet\u002Fcore\u002Fweb-api\u002Fhandle-errors",[561],[3655],{"type":49,"value":3656},"Handle errors in ASP.NET Core APIs",{"type":49,"value":3658}," — Problem Details and exception handling",{"type":43,"tag":74,"props":3660,"children":3661},{},[3662,3667],{"type":43,"tag":557,"props":3663,"children":3665},{"href":610,"rel":3664},[561],[3666],{"type":49,"value":577},{"type":49,"value":3668}," — preferred type for date\u002Ftime values in APIs",{"type":43,"tag":3670,"props":3671,"children":3672},"style",{},[3673],{"type":49,"value":3674},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":3676,"total":3840},[3677,3693,3708,3723,3741,3755,3774,3784,3796,3806,3819,3830],{"slug":3678,"name":3678,"fn":3679,"description":3680,"org":3681,"tags":3682,"stars":3690,"repoUrl":3691,"updatedAt":3692},"multithreaded-task-migration","migrate MSBuild tasks to multithreaded mode","Guide for migrating MSBuild tasks to multithreaded mode support, including compatibility red-team review. Use this when converting tasks to thread-safe versions, implementing IMultiThreadableTask, adding TaskEnvironment support, or auditing migrations for behavioral compatibility.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3683,3684,3687],{"name":13,"slug":14,"type":15},{"name":3685,"slug":3686,"type":15},"Engineering","engineering",{"name":3688,"slug":3689,"type":15},"Performance","performance",5535,"https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fmsbuild","2026-07-22T05:37:33.965588",{"slug":3694,"name":3694,"fn":3695,"description":3696,"org":3697,"tags":3698,"stars":25,"repoUrl":26,"updatedAt":3707},"analyzing-dotnet-performance","analyze .NET code for performance anti-patterns","Scans .NET code for ~50 performance anti-patterns across async, memory, strings, collections, LINQ, regex, serialization, and I\u002FO with tiered severity classification. Use when analyzing .NET code for optimization opportunities, reviewing hot paths, or auditing allocation-heavy patterns.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3699,3700,3703,3706],{"name":13,"slug":14,"type":15},{"name":3701,"slug":3702,"type":15},"Code Analysis","code-analysis",{"name":3704,"slug":3705,"type":15},"Debugging","debugging",{"name":3688,"slug":3689,"type":15},"2026-07-12T08:23:25.400375",{"slug":3709,"name":3709,"fn":3710,"description":3711,"org":3712,"tags":3713,"stars":25,"repoUrl":26,"updatedAt":3722},"android-tombstone-symbolication","symbolicate .NET runtime frames in Android tombstones","Symbolicate the .NET runtime frames in an Android tombstone file. Extracts BuildIds and PC offsets from the native backtrace, downloads debug symbols from the Microsoft symbol server, and runs llvm-symbolizer to produce function names with source file and line numbers. USE FOR triaging a .NET MAUI or Mono Android app crash from a tombstone, resolving native backtrace frames in libmonosgen-2.0.so or libcoreclr.so to .NET runtime source code, or investigating SIGABRT, SIGSEGV, or other native signals originating from the .NET runtime on Android. DO NOT USE FOR pure Java\u002FKotlin crashes, managed .NET exceptions that are already captured in logcat, or iOS crash logs. INVOKES Symbolicate-Tombstone.ps1 script, llvm-symbolizer, Microsoft symbol server.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3714,3715,3718,3719],{"name":13,"slug":14,"type":15},{"name":3716,"slug":3717,"type":15},"Android","android",{"name":3704,"slug":3705,"type":15},{"name":3720,"slug":3721,"type":15},"Microsoft","microsoft","2026-07-12T08:23:21.595572",{"slug":3724,"name":3724,"fn":3725,"description":3726,"org":3727,"tags":3728,"stars":25,"repoUrl":26,"updatedAt":3740},"apple-crash-symbolication","symbolicate .NET runtime frames in crash logs","Symbolicate .NET runtime frames in Apple platform .ips crash logs (iOS, tvOS, Mac Catalyst, macOS). Extracts UUIDs and addresses from the native backtrace, locates dSYM debug symbols, and runs atos to produce function names with source file and line numbers. Automatically downloads .dwarf symbols from the Microsoft symbol server using Mach-O UUIDs. USE FOR triaging a .NET MAUI or Mono app crash from an .ips file on any Apple platform, resolving native backtrace frames in libcoreclr or libmonosgen-2.0 to .NET runtime source code, retrieving .ips crash logs from a connected iOS device or iPhone, or investigating EXC_CRASH, EXC_BAD_ACCESS, SIGABRT, or SIGSEGV originating from the .NET runtime. DO NOT USE FOR pure Swift\u002FObjective-C crashes with no .NET components, or Android tombstone files. INVOKES Symbolicate-Crash.ps1 script, atos, dwarfdump, idevicecrashreport.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3729,3730,3731,3734,3737],{"name":13,"slug":14,"type":15},{"name":3704,"slug":3705,"type":15},{"name":3732,"slug":3733,"type":15},"iOS","ios",{"name":3735,"slug":3736,"type":15},"macOS","macos",{"name":3738,"slug":3739,"type":15},"Observability","observability","2026-07-12T08:23:20.369986",{"slug":3742,"name":3742,"fn":3743,"description":3744,"org":3745,"tags":3746,"stars":25,"repoUrl":26,"updatedAt":3754},"assertion-quality","evaluate assertion quality in test suites","Analyzes the variety and depth of assertions across test suites in any language. Use when the user asks to evaluate assertion quality, find shallow tests, identify assertion-free tests (no assertions or only trivial ones like Assert.IsNotNull \u002F toBeTruthy()), flag self-referential or tautological assertions, measure assertion diversity, or audit whether tests verify different facets of behavior. Polyglot: .NET, Python, TS\u002FJS, Java, Go, Ruby, Rust, Swift, Kotlin, PowerShell, C++. DO NOT USE FOR: writing new tests (use code-testing-agent \u002F writing-mstest-tests), mutation reasoning about whether tests would catch a bug (use test-gap-analysis), or a general severity-ranked anti-pattern audit (use test-anti-patterns), fixing or rewriting assertions, or writing, fixing, or modernizing MSTest tests, assertions, or attributes (use writing-mstest-tests).",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3747,3748,3751],{"name":3701,"slug":3702,"type":15},{"name":3749,"slug":3750,"type":15},"QA","qa",{"name":3752,"slug":3753,"type":15},"Testing","testing","2026-07-12T08:23:51.277743",{"slug":3756,"name":3756,"fn":3757,"description":3758,"org":3759,"tags":3760,"stars":25,"repoUrl":26,"updatedAt":3773},"author-component","create and review Blazor components","Create or review Blazor components (.razor files) with correct architecture. USE FOR: writing new Blazor components that do NOT involve JavaScript interop, implementing parameters and EventCallback, RenderFragment slots, component lifecycle (OnInitializedAsync, OnParametersSet), async patterns, IAsyncDisposable, CancellationToken, CSS isolation, code-behind. DO NOT USE FOR: creating new projects (use create-blazor-project), JavaScript interop or calling browser APIs from Blazor (use use-js-interop), forms and validation (use collect-user-input), prerendering issues (use support-prerendering), HTTP data fetching patterns (use fetch-and-send-data), coordinating state between unrelated components (use coordinate-components).\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3761,3762,3765,3767,3770],{"name":13,"slug":14,"type":15},{"name":3763,"slug":3764,"type":15},"Blazor","blazor",{"name":3766,"slug":640,"type":15},"C#",{"name":3768,"slug":3769,"type":15},"UI Components","ui-components",{"name":3771,"slug":3772,"type":15},"Web Development","web-development","2026-07-15T06:03:29.216359",{"slug":3775,"name":3775,"fn":3776,"description":3777,"org":3778,"tags":3779,"stars":25,"repoUrl":26,"updatedAt":3783},"binlog-failure-analysis","analyze MSBuild binary logs","Analyze MSBuild binary logs to diagnose build failures. USE FOR: build errors that are unclear from console output, diagnosing cascading failures across multi-project builds, tracing MSBuild target execution order, and generally any MSBuild build issues. Requires an existing .binlog file. DO NOT USE FOR: generating binlogs (use binlog-generation), non-MSBuild build systems.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3780,3781,3782],{"name":3701,"slug":3702,"type":15},{"name":3704,"slug":3705,"type":15},{"name":3720,"slug":3721,"type":15},"2026-07-12T08:21:34.637923",{"slug":3785,"name":3785,"fn":3786,"description":3787,"org":3788,"tags":3789,"stars":25,"repoUrl":26,"updatedAt":3795},"binlog-generation","generate MSBuild binary logs for diagnostics","Generate MSBuild binary logs (binlogs) for build diagnostics and analysis. USE FOR: adding \u002Fbl:{} to any dotnet build, test, pack, publish, or restore command to capture a full build execution trace, prerequisite for binlog-failure-analysis and build-perf-diagnostics skills, enabling post-build investigation of errors or performance. Requires MSBuild 17.8+ \u002F .NET 8 SDK+ for {} placeholder; PowerShell needs -bl:{{}}. DO NOT USE FOR: non-MSBuild build systems (npm, Maven, CMake), analyzing an existing binlog (use binlog-failure-analysis instead).",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3790,3793,3794],{"name":3791,"slug":3792,"type":15},"Build","build",{"name":3704,"slug":3705,"type":15},{"name":3685,"slug":3686,"type":15},"2026-07-19T05:38:19.340791",{"slug":3797,"name":3797,"fn":3798,"description":3799,"org":3800,"tags":3801,"stars":25,"repoUrl":26,"updatedAt":3805},"build-parallelism","optimize MSBuild build parallelism","Diagnose and fix under-parallelized MSBuild builds. USE WHEN a multi-project solution build is slower than expected, doesn't speed up when you add cores, pegs a single core while others idle, or you want to know why `-m` isn't helping. Note: `\u002Fmaxcpucount` default is 1 (sequential) — always pass `-m` for parallel builds. Covers finding the critical path (longest serial ProjectReference chain), graph build (`\u002Fgraph`), BuildInParallel, and solution filters (`.slnf`). DO NOT USE FOR: single-project builds, incremental issues (use incremental-build), compilation slowness inside one project (use build-perf-diagnostics), non-MSBuild build systems.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3802,3803,3804],{"name":13,"slug":14,"type":15},{"name":3685,"slug":3686,"type":15},{"name":3688,"slug":3689,"type":15},"2026-07-19T05:38:18.364937",{"slug":3807,"name":3807,"fn":3808,"description":3809,"org":3810,"tags":3811,"stars":25,"repoUrl":26,"updatedAt":3818},"build-perf-baseline","establish and optimize build performance baselines","Establish build performance baselines and apply systematic optimization techniques. USE FOR: diagnosing slow builds, establishing before\u002Fafter measurements (cold, warm, no-op scenarios), applying optimization strategies like MSBuild Server, static graph builds, artifacts output, and dependency graph trimming. Start here before diving into build-perf-diagnostics, incremental-build, or build-parallelism. DO NOT USE FOR: non-MSBuild build systems, detailed bottleneck analysis (use build-perf-diagnostics after baselining).",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3812,3813,3816,3817],{"name":3685,"slug":3686,"type":15},{"name":3814,"slug":3815,"type":15},"Monitoring","monitoring",{"name":3688,"slug":3689,"type":15},{"name":3752,"slug":3753,"type":15},"2026-07-12T08:21:35.865649",{"slug":3820,"name":3820,"fn":3821,"description":3822,"org":3823,"tags":3824,"stars":25,"repoUrl":26,"updatedAt":3829},"build-perf-diagnostics","diagnose MSBuild build performance bottlenecks","Diagnose MSBuild build performance bottlenecks using binary log analysis. USE FOR: identifying why builds are slow by analyzing binlog performance summaries, detecting ResolveAssemblyReference (RAR) taking >5s, Roslyn analyzers consuming >30% of Csc time, single targets dominating >50% of build time, node utilization below 80%, excessive Copy tasks, NuGet restore running every build. Covers timeline analysis, Target\u002FTask Performance Summary interpretation, and 7 common bottleneck categories. Use after build-perf-baseline has established measurements. DO NOT USE FOR: establishing initial baselines (use build-perf-baseline first), fixing incremental build issues (use incremental-build), parallelism tuning (use build-parallelism), non-MSBuild build systems.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3825,3826,3827,3828],{"name":13,"slug":14,"type":15},{"name":3704,"slug":3705,"type":15},{"name":3685,"slug":3686,"type":15},{"name":3688,"slug":3689,"type":15},"2026-07-12T08:21:40.961722",{"slug":3831,"name":3831,"fn":3832,"description":3833,"org":3834,"tags":3835,"stars":25,"repoUrl":26,"updatedAt":3839},"check-bin-obj-clash","detect MSBuild output path conflicts","Detects MSBuild projects with conflicting OutputPath or IntermediateOutputPath. USE FOR: builds failing with 'Cannot create a file when that file already exists', 'The process cannot access the file because it is being used by another process', intermittent build failures that succeed on retry, or missing\u002Foverwritten outputs in multi-project or multi-targeting builds where bin\u002Fobj (or project.assets.json) collide. Common causes: shared OutputPath, missing AppendTargetFrameworkToOutputPath, extra global properties (e.g. PublishReadyToRun), or SetTargetFramework on a ProjectReference to a single-targeting project. DO NOT USE FOR: file access errors unrelated to MSBuild (OS-level locking), single-project single-TFM builds, non-MSBuild build systems.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3836,3837,3838],{"name":3704,"slug":3705,"type":15},{"name":3685,"slug":3686,"type":15},{"name":3749,"slug":3750,"type":15},"2026-07-19T05:38:14.336279",144,{"items":3842,"total":3891},[3843,3850,3857,3865,3871,3879,3885],{"slug":3694,"name":3694,"fn":3695,"description":3696,"org":3844,"tags":3845,"stars":25,"repoUrl":26,"updatedAt":3707},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3846,3847,3848,3849],{"name":13,"slug":14,"type":15},{"name":3701,"slug":3702,"type":15},{"name":3704,"slug":3705,"type":15},{"name":3688,"slug":3689,"type":15},{"slug":3709,"name":3709,"fn":3710,"description":3711,"org":3851,"tags":3852,"stars":25,"repoUrl":26,"updatedAt":3722},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3853,3854,3855,3856],{"name":13,"slug":14,"type":15},{"name":3716,"slug":3717,"type":15},{"name":3704,"slug":3705,"type":15},{"name":3720,"slug":3721,"type":15},{"slug":3724,"name":3724,"fn":3725,"description":3726,"org":3858,"tags":3859,"stars":25,"repoUrl":26,"updatedAt":3740},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3860,3861,3862,3863,3864],{"name":13,"slug":14,"type":15},{"name":3704,"slug":3705,"type":15},{"name":3732,"slug":3733,"type":15},{"name":3735,"slug":3736,"type":15},{"name":3738,"slug":3739,"type":15},{"slug":3742,"name":3742,"fn":3743,"description":3744,"org":3866,"tags":3867,"stars":25,"repoUrl":26,"updatedAt":3754},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3868,3869,3870],{"name":3701,"slug":3702,"type":15},{"name":3749,"slug":3750,"type":15},{"name":3752,"slug":3753,"type":15},{"slug":3756,"name":3756,"fn":3757,"description":3758,"org":3872,"tags":3873,"stars":25,"repoUrl":26,"updatedAt":3773},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3874,3875,3876,3877,3878],{"name":13,"slug":14,"type":15},{"name":3763,"slug":3764,"type":15},{"name":3766,"slug":640,"type":15},{"name":3768,"slug":3769,"type":15},{"name":3771,"slug":3772,"type":15},{"slug":3775,"name":3775,"fn":3776,"description":3777,"org":3880,"tags":3881,"stars":25,"repoUrl":26,"updatedAt":3783},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3882,3883,3884],{"name":3701,"slug":3702,"type":15},{"name":3704,"slug":3705,"type":15},{"name":3720,"slug":3721,"type":15},{"slug":3785,"name":3785,"fn":3786,"description":3787,"org":3886,"tags":3887,"stars":25,"repoUrl":26,"updatedAt":3795},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3888,3889,3890],{"name":3791,"slug":3792,"type":15},{"name":3704,"slug":3705,"type":15},{"name":3685,"slug":3686,"type":15},96]