You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ASP.NET Core supports the generation of OpenAPI documents in controller-based and Minimal API apps.
4
+
The [OpenAPI specification](https://spec.openapis.org/oas/latest.html) is a programming language-agnostic standard for documenting HTTP APIs. This standard is supported in ASP.NET Core apps through a combination of built-in APIs and open-source libraries. There are three key aspects to OpenAPI integration in an application:
5
+
6
+
* Generating information about the endpoints in the app.
7
+
* Gathering the information into a format that matches the OpenAPI schema.
8
+
* Exposing the generated OpenAPI document via a visual UI or a serialized file.
9
+
10
+
ASP.NET Core provides first-party support for generating information about endpoints in an app through the `Microsoft.AspNetCore.OpenApi` package.
11
+
12
+
13
+
The following code is generated by the ASP.NET Core minimal web API template and uses OpenAPI:
*`AddOpenApi` registers services required for OpenAPI document generation into the application's DI container.
20
+
*`MapOpenApi` adds an endpoint into the application for viewing the OpenAPI document serialized into JSON. The OpenAPI endpoint is restricted to the `Development` environment to minimize the risk of exposing sensitive information and reduce the vulnerabilities in production.
21
+
22
+
<aname="openapinuget"></a>
23
+
24
+
## `Microsoft.AspNetCore.OpenApi` NuGet package
25
+
26
+
The [`Microsoft.AspNetCore.OpenApi`](https://www.nuget.org/packages/Microsoft.AspNetCore.OpenApi/) package provides the following features:
27
+
28
+
* Support for generating OpenAPI documents at run time and accessing them via an endpoint on the application.
29
+
* Support for "transformer" APIs that modify the generated document.
30
+
31
+
To use the `Microsoft.AspNetCore.OpenApi` package, add it as a PackageReference to a project file:
The [`Microsoft.Extensions.ApiDescription.Server`](https://www.nuget.org/packages/Microsoft.Extensions.ApiDescription.Server/) package provides support for generating OpenAPI documents at build time and serializing them.
40
+
41
+
To use `Microsoft.Extensions.ApiDescription.Server`, add it as a PackageReference to a project file.
42
+
Document generation at build time is enabled by setting the `OpenApiGenerateDocuments` property.
43
+
By default, the generated OpenAPI document is saved to the `obj` directory, but you can customize
44
+
the output directory by setting the `OpenApiDocumentsDirectory` property.
title: Overview of OpenAPI support in ASP.NET Core API apps
3
+
ai-usage: ai-assisted
3
4
author: wadepickett
4
-
description: Learn about OpenAPI features in ASP.NET Core.
5
-
ms.author: wpickett
5
+
description: Learn how to integrate OpenAPI in ASP.NET Core API apps. Discover features, tools, and packages for generating and customizing OpenAPI documents.
6
6
monikerRange: '>= aspnetcore-6.0'
7
-
ms.date: 05/14/2025
7
+
ms.author: wpickett
8
+
ms.reviewer: wpickett
9
+
ms.date: 03/20/2026
8
10
uid: fundamentals/openapi/overview
9
11
---
10
12
# OpenAPI support in ASP.NET Core API apps
11
13
12
14
[!INCLUDE[](~/includes/not-latest-version.md)]
13
15
14
-
:::moniker range=">= aspnetcore-9.0"
16
+
:::moniker range=">= aspnetcore-10.0"
15
17
16
-
ASP.NET Core supports the generation of OpenAPI documents in controller-based and Minimal APIs apps.
17
-
The [OpenAPI specification](https://spec.openapis.org/oas/latest.html) is a programming language-agnostic standard for documenting HTTP APIs. This standard is supported in ASP.NET Core apps through a combination of built-in APIs and open-source libraries. There are three key aspects to OpenAPI integration in an application:
18
+
ASP.NET Core supports the generation of OpenAPI documents in controller-based and Minimal API apps.
19
+
The [OpenAPI specification](https://spec.openapis.org/oas/latest.html) is a programming language-agnostic standard for documenting HTTP APIs. ASP.NET Core apps support this standard through a combination of built-in APIs and open-source libraries. There are three key aspects to OpenAPI integration in an application:
18
20
19
21
* Generating information about the endpoints in the app.
20
22
* Gathering the information into a format that matches the OpenAPI schema.
21
-
* Exposing the generated OpenAPI document via a visual UI or a serialized file.
22
-
23
-
ASP.NET Core apps provide built-in support for generating information about endpoints in an app via the `Microsoft.AspNetCore.OpenApi` package.
23
+
* Exposing the generated OpenAPI document through a visual UI or a serialized file.
24
24
25
-
<!-- TODO: Merge content from controllers overview here, as appropriate -->
25
+
ASP.NET Core provides first-party support for generating information about endpoints in an app through the `Microsoft.AspNetCore.OpenApi` package.
26
26
27
-
The following code is generated by the ASP.NET Core minimal web API template and uses OpenAPI:
27
+
The ASP.NET Core minimal web API template generates the following code that uses OpenAPI:
The [`Microsoft.Extensions.ApiDescription.Server`](https://www.nuget.org/packages/Microsoft.Extensions.ApiDescription.Server/) package provides support for generating OpenAPI documents at build time and serializing them.
53
+
The [`Microsoft.Extensions.ApiDescription.Server`](https://www.nuget.org/packages/Microsoft.Extensions.ApiDescription.Server/) package supports generating OpenAPI documents at build time and serializing them.
54
54
55
55
To use `Microsoft.Extensions.ApiDescription.Server`, add it as a PackageReference to a project file.
56
-
Document generation at build time is enabled by setting the `OpenApiGenerateDocuments` property.
56
+
Enable document generation at build time by setting the `OpenApiGenerateDocuments` property.
57
57
By default, the generated OpenAPI document is saved to the `obj` directory, but you can customize
58
58
the output directory by setting the `OpenApiDocumentsDirectory` property.
0 commit comments