diff --git a/aspnetcore/tutorials/web-api-help-pages-using-swagger.md b/aspnetcore/tutorials/web-api-help-pages-using-swagger.md index 00ec6fc2d2d3..5227f5dfd634 100644 --- a/aspnetcore/tutorials/web-api-help-pages-using-swagger.md +++ b/aspnetcore/tutorials/web-api-help-pages-using-swagger.md @@ -1,11 +1,12 @@ --- title: ASP.NET Core web API documentation with Swagger / OpenAPI +ai-usage: ai-assisted author: RicoSuter description: This tutorial provides a walkthrough of adding Swagger to generate documentation and help pages for a web API app. ms.author: wpickett ms.custom: mvc monikerRange: ">= aspnetcore-3.1 <= aspnetcore-8.0" -ms.date: 4/25/2024 +ms.date: 02/23/2026 uid: tutorials/web-api-help-pages-using-swagger --- # ASP.NET Core web API documentation with Swagger / OpenAPI @@ -14,6 +15,15 @@ uid: tutorials/web-api-help-pages-using-swagger By [Rico Suter](https://blog.rsuter.com/) +This article covers using **Swagger** tooling — provided by the [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) and [NSwag](https://github.com/RicoSuter/NSwag) packages — to generate OpenAPI documentation and interactive help pages for ASP.NET Core web APIs. + +In .NET 9 and later, ASP.NET Core includes built-in OpenAPI support that replaces Swashbuckle as the default. Swashbuckle is no longer included in project templates, but it remains available as a community package you can add manually. + +* To understand the built‑in OpenAPI features, see . +* To add Swagger UI for interactive exploration or local ad‑hoc testing alongside the built-in OpenAPI support, see . + +The following instructions apply to projects using Swashbuckle or NSwag with ASP.NET Core 8.0 and earlier. + [Swagger](https://swagger.io/) ([OpenAPI](https://www.openapis.org/)) is a language-agnostic specification for describing REST APIs. It allows both computers and humans to understand the capabilities of a REST API without direct access to the source code. Its main goals are to: * Minimize the amount of work needed to connect decoupled services. @@ -147,12 +157,14 @@ In the preceding code, the `/weatherforecast` endpoint doesn't need authorizatio The following Curl passes a JWT token to test the Swagger UI endpoint: ```bash -curl -i -H "Authorization: Bearer {token}" https://localhost:{port}/swagger/v1/swagger.json +curl -i -H "Authorization: Bearer {TOKEN}" https://localhost:{PORT}/swagger/v1/swagger.json ``` +where the `{TOKEN}` placeholder is the JWT bearer token and the `{PORT}` placeholder is the port number. + For more information on testing with JWT tokens, see . -## Generate an XML documentation file at compile time. +## Generate an XML documentation file at compile time See [GenerateDocumentationFile](/dotnet/core/project-sdk/msbuild-props#generatedocumentationfile) for more information.