Min Web API tutorial rewrite plus app samples updates v10#37294
Min Web API tutorial rewrite plus app samples updates v10#37294wadepickett wants to merge 3 commits into
Conversation
mikekistler
left a comment
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Is there some reason to use NSwag? Our docs:
describe how to add either SwaggerUI (from Swashbuckle) or Scalar but not NSwag. Should we be consistent?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
| * 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. |
There was a problem hiding this comment.
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.
|
|
||
| # [Visual Studio Code](#tab/visual-studio-code) | ||
|
|
||
| Use Swagger to send a PUT request: |
There was a problem hiding this comment.
| Use the Swagger UI to send a PUT request: |
|
|
||
| # [Visual Studio Code](#tab/visual-studio-code) | ||
|
|
||
| Use Swagger to send a PATCH request: |
There was a problem hiding this comment.
| Use the Swagger UI to send a PATCH request: |
|
|
||
| # [Visual Studio Code](#tab/visual-studio-code) | ||
|
|
||
| Use Swagger to send a DELETE request: |
There was a problem hiding this comment.
| Use the Swagger UI to send a DELETE request: |
|
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>
Rewrite the Minimal Web API tutorial to:
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