Skip to content

Min Web API tutorial rewrite plus app samples updates v10#37294

Draft
wadepickett wants to merge 3 commits into
mainfrom
wadepickett/37018MinWebAPIupdateTry4
Draft

Min Web API tutorial rewrite plus app samples updates v10#37294
wadepickett wants to merge 3 commits into
mainfrom
wadepickett/37018MinWebAPIupdateTry4

Conversation

@wadepickett

@wadepickett wadepickett commented Jun 25, 2026

Copy link
Copy Markdown
Contributor
  1. Rewrite the Minimal Web API tutorial to:

    • Start with the template set to provide OpenAPI support. rather then an empty project
    • Use OpenAPI for the VS Code with only using the NSwag package's Swagger UI to read the OpenAPI document.
  2. Updates all 8 app samples used by this tutorial for .NET 10 using the ASP.NET Core Web API (webapi for CLI) template.

After this PR is completed/merged:
Update in a new PR refer to final complete app version VS (using .http testing files) and VS Code (using Swagger UI)version on the AspNetCore.docs.samples repo which can be run in Codespaces.


Internal previews

📄 File 🔗 Preview link
aspnetcore/tutorials/min-web-api.md Tutorial: Create a Minimal API with ASP.NET Core

@wadepickett wadepickett self-assigned this Jun 25, 2026

@mikekistler mikekistler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. 👍

I left a few nit-picky comments, but one bigger concern is using NSwag. I think I'd prefer that we use either SwagggerUI from Swashbuckle or Scalar, since those are the ones we describe elsewhere in the docs.

[!code-csharp[](~/tutorials/min-web-api/samples/9.x/todo/Program.cs?name=snippet_DI&highlight=2-3)]
[!code-csharp[](~/tutorials/min-web-api/samples/10.x/todo/Program.cs?name=snippet_DI&highlight=2)]

The DI container provides access to the database context and other services.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to explain that "ToDoList" is the name of the in-memory database.

### Add a browser UI to view the OpenAPI document

### Install Swagger tooling
The template already generates the OpenAPI document at `/openapi/v1.json`. To explore and test the API from a browser, add a UI that consumes that document. This tutorial uses NSwag.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some reason to use NSwag? Our docs:

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/using-openapi-documents?view=aspnetcore-10.0

describe how to add either SwaggerUI (from Swashbuckle) or Scalar but not NSwag. Should we be consistent?

@wadepickett wadepickett Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I accidently used it out of old habit I think. It was a mistake. I was using SwaggerUI, which is packaged in NSwag but I should have used the Swashbuckle package if doing so. Thanks.

# [Visual Studio Code](#tab/visual-studio-code)

* With the app still running, in the browser, navigate to `https://localhost:<port>/swagger` to display the API testing page generated by Swagger.
* With the app still running, in the browser, navigate to `https://localhost:{port}/swagger` to display the API testing page generated by Swagger.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* With the app still running, in the browser, navigate to `https://localhost:{port}/swagger` to display the API testing page generated by Swagger.
* With the app still running, in the browser, navigate to `https://localhost:{port}/swagger` to display the API testing page generated by NSwag.

or other package if we decided to use SwaggerUI or Scalar.


---

This app uses an in-memory database. If the app is restarted, the GET request doesn't return any data. If no data is returned, [POST](#post) data to the app and try the GET request again.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the app is restarted, GET for the list of todos returns an empty array, and GET with an id field will return a 404 Not Found.

Comment thread aspnetcore/tutorials/min-web-api.md Outdated

# [Visual Studio Code](#tab/visual-studio-code)

Use Swagger to send a PUT request:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use the Swagger UI to send a PUT request:


# [Visual Studio Code](#tab/visual-studio-code)

Use Swagger to send a PATCH request:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use the Swagger UI to send a PATCH request:


# [Visual Studio Code](#tab/visual-studio-code)

Use Swagger to send a DELETE request:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use the Swagger UI to send a DELETE request:

@wadepickett

Copy link
Copy Markdown
Contributor Author

OK thanks! It was using Swagger UI, but you are right, it was coming from the Nswag package. I will change it.

Co-authored-by: Mike Kistler <mikekistler@microsoft.com>
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.

2 participants