Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions aspnetcore/tutorials/web-api-help-pages-using-swagger.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 <xref:fundamentals/openapi/overview?view=aspnetcore-9.0&preserve-view=true>.
* To add Swagger UI for interactive exploration or local ad‑hoc testing alongside the built-in OpenAPI support, see <xref:fundamentals/openapi/using-openapi-documents#use-swagger-ui-for-local-ad-hoc-testing>.

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.
Expand Down Expand Up @@ -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 <xref:security/authentication/jwt>.

## 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.

Expand Down