Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

Fixes #33789

The minimal API tutorial was missing PATCH operation examples despite MapPatch being introduced in .NET 7.

Changes

Documentation updates (for .NET 7, 8, 9 monikers):

  • Added PATCH endpoint to API overview tables
  • Added "Examine the PATCH endpoint" and "Test the PATCH endpoint" sections
  • Included testing instructions for both Visual Studio (Endpoints Explorer/.http files) and VS Code (Swagger UI)
  • Added NOTE block cross-referencing <xref:web-api/jsonpatch> for advanced scenarios

Sample code:

  • Added snippet_patch to Program.cs files in samples/{7.x,8.x,9.x}/todo/
  • Implementation demonstrates partial update pattern:
app.MapPatch("/todoitems/{id}", async (int id, Todo inputTodo, TodoDb db) =>
{
    var todo = await db.Todos.FindAsync(id);
    if (todo is null) return Results.NotFound();
    
    if (inputTodo.Name is not null) todo.Name = inputTodo.Name;
    if (inputTodo.IsComplete != todo.IsComplete) todo.IsComplete = inputTodo.IsComplete;
    
    await db.SaveChangesAsync();
    return Results.NoContent();
});

Metadata:

  • Updated ms.date to 11/13/2025
  • Added ai-usage: ai-assisted
Original prompt

This section details on the original issue you should resolve

<issue_title>Add PATCH to tutorial</issue_title>
<issue_description>### Description

Verbatim:

It doesn't have example of a PATCH operation. Microsoft added MapPatch support in .net7 but didn't added an example of it in this documentation page. It would be useful if Microsoft add an example which uses MapPut and JsonPatch in the net core template for minimal api.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/tutorials/min-web-api?view=aspnetcore-8.0&tabs=visual-studio

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/tutorials/min-web-api.md

Document ID

ab408035-6313-a183-9940-32de00e0e977

Article author

@wadepickett</issue_description>

Comments on the Issue (you are @copilot in this section)

@wadepickett AI analysis test run by wadepickett Prompt: verify-issue-set-course-of-action_v.05.md Model: GPT-4 Nov 2023 -------

Issue Analysis: Add PATCH to tutorial

Issue Summary

This is a valid issue. The user reports that the minimal API tutorial for ASP.NET Core does not include an example for a PATCH operation, specifically using MapPatch and (optionally) JsonPatchDocument in the .NET minimal API template. PATCH support was introduced in .NET 7 but is not demonstrated in the current tutorial.

Issue Context and Validation

  • Article evaluated: Tutorial: Create a minimal API with ASP.NET Core

  • Source file path: aspnetcore/tutorials/min-web-api.md

  • Current status:

    • No PATCH Example: The table and main API walkthrough provide GET, POST, PUT, DELETE; no PATCH endpoint is included for updating partial resources.
    • No mention of MapPatch or JsonPatch: The file does not show usage (sample code or instruction) for PATCH-specific minimal API patterns, nor how to apply JSON Patch documents.
    • Tutorial scope and audience (minimal API, .NET 6–9): The visible section of the tutorial is geared to basics and practical "CRUD" with PUT and POST, but PATCH is now a canonical REST verb and should be covered at least in .NET 7+ coverage.
  • Recent related/overlapping issues:

    • Numerous closed or open issues on PATCH, MapPatch, and JsonPatch in the repo—but primarily in advanced topics, Blazor articles, or dedicated jsonpatch.md.
    • This tutorial still does not describe PATCH in the visual walkthrough or add a PATCH endpoint for minimal APIs.
  • No effective workaround or cross-reference: The article does not redirect readers to dedicated PATCH or JsonPatch documentation, so discoverability in the tutorial context is poor.

  • Has the issue already been addressed?

    • No. As of the latest HEAD, there is no PATCH sample or mention in the tutorial—confirmed by direct review of the min-web-api.md at HEAD and the accompanying sample code.

Affected File(s) and Section(s)

  • File to update:

    • aspnetcore/tutorials/min-web-api.md
  • Sections impacted:

    • "Overview" Table: Add PATCH endpoint row
    • API Implementation Steps: Add PATCH endpoint code (ideally after PUT section)
    • Testing steps: Add PATCH example in .http file (VS/VS Code) and Swagger instructions

Recommended Documentation Update

  1. Add PATCH endpoint to "Overview" Table:

    • Describe PATCH operation, request/response body requirements, and intent (partial resource update).
  2. Provide PATCH minimal API sample code:

    • Add MapPatch endpoint to the example, updating partial fields for a todo item.
    • If using .NET 7+, optionally add an example using JsonPatchDocument<Todo> for advanced partial updates.
  3. Update step-by-step instructions:

    • Include PATCH request sample (in .http file and in Swagger UI testing steps).
    • Demonstrate use and limitations of PATCH as compared to PUT.
  4. Add a tip/note block:

    • e.g., [!NOTE] PATCH provides partial updates and can leverage JsonPatch for complex scenarios.
  5. Reference dedicated guidance:

Example Code or CLI Snippets (if applicable)

Basic PATCH with direct property assignment (Recommended for tutorial simplicity):

todoItems.MapPatch("/{id}", async (int id, TodoPatchDto patch, TodoDb db) =>
{
    var todoItem = await db.Todos.FindAsync(id);
    if (todoItem is null) return Results.NotFound();
    if (patch.Name is not null) todoItem.Name = patch.Name;
...

</details>

- Fixes dotnet/AspNetCore.Docs#33789

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).

Copilot AI changed the title [WIP] Add PATCH example to minimal API tutorial Add PATCH endpoint documentation to minimal API tutorial Nov 13, 2025
Copilot AI requested a review from wadepickett November 13, 2025 19:39
Copilot finished work on behalf of wadepickett November 13, 2025 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add PATCH to tutorial

2 participants