OpenAPI documentation plays an important role in modern ASP.NET Core applications. It describes API endpoints, request parameters, response formats, authentication requirements, and error responses. Developers use this information to generate client libraries, integrate external services, and understand how an API behaves.
As APIs evolve, their documentation standards also change. OpenAPI 3.2 introduces improvements that help describe modern API capabilities, including HTTP QUERY operations, Server-Sent Events, and more accurate response schemas.
ASP.NET Core provides built-in OpenAPI document generation through the Microsoft.AspNetCore.OpenApi package. However, moving to a newer OpenAPI specification is not always a simple configuration change. Existing API consumers may depend on older documentation formats, and some code generators, validation tools, and API management platforms may not fully support the newer specification.
The important point is that upgrading OpenAPI documentation should not automatically require changing the actual API contract.
In this article, we will explore how OpenAPI 3.2 works in ASP.NET Core, how to configure it, and how to introduce the newer specification without unnecessarily affecting existing API clients.
Understanding OpenAPI 3.2 in ASP.NET Core
OpenAPI is a standard for describing HTTP APIs in a machine-readable format. It allows developers and tools to understand an API without examining its implementation.
An OpenAPI document typically describes:
- Available API endpoints and HTTP methods.
- Request parameters and request body schemas.
- Response status codes and response structures.
- Authentication and authorization requirements.
- Supported content types.
- Reusable schemas and components.
ASP.NET Core supports OpenAPI document generation through the Microsoft.AspNetCore.OpenApi package.
The supported default versions depend on the target framework:
| Platform |
Default OpenAPI version |
| .NET 9 |
OpenAPI 3.0 |
| .NET 10 |
OpenAPI 3.1 |
| .NET 11 |
OpenAPI 3.2 |
Starting with .NET 11, ASP.NET Core generates OpenAPI 3.2 documents by default.
This does not mean existing APIs automatically change their HTTP behavior. The specification version describes the API contract in a document. It does not independently change endpoint routes, authentication rules, or response behavior.
However, tools that consume the document must understand the specification version and the features used in it.
Why Updating OpenAPI Can Affect Existing API Clients
Consider an ASP.NET Core application that exposes customer and order management APIs.
The application generates an OpenAPI document, which is consumed by several systems:
- A frontend application uses generated TypeScript clients.
- A mobile application team uses generated API models.
- An integration partner imports the specification into its development tools.
- An API management platform validates and publishes API definitions.
- Automated tests compare the generated document against an approved API contract.
Now imagine upgrading the application to .NET 11.
The generated OpenAPI document uses version 3.2 by default. Some existing tools may still expect OpenAPI 3.0 or 3.1.
This can introduce problems such as:
- Client generation failures.
- Unsupported schema features.
- Differences in generated models.
- Validation errors in older API management tools.
- Incompatible documentation imports.
It is important to understand that these problems do not necessarily indicate that the actual API endpoints are broken. They may be caused by differences in how downstream tools interpret the newer OpenAPI document.
Therefore, upgrading the documentation format should be treated as a compatibility exercise.
Configuring OpenAPI 3.2 in ASP.NET Core
Let's start with a basic ASP.NET Core application.
Step 1. Install the OpenAPI Package
Add the Microsoft.AspNetCore.OpenApi package to your ASP.NET Core project.
For a .NET 11 application, use the package version compatible with the target framework.
The project file should contain a package reference similar to the following:
<ItemGroup>
<PackageReference
Include="Microsoft.AspNetCore.OpenApi"
Version="11.0.0" />
</ItemGroup>
Use the appropriate stable servicing version available for your project rather than assuming that every package version is interchangeable.
Step 2. Register OpenAPI Services
Open Program.cs and register OpenAPI document generation.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();
var app = builder.Build();
app.MapOpenApi();
app.Run();
The AddOpenApi method registers the services required to generate the OpenAPI document.
The MapOpenApi method exposes the generated document through an HTTP endpoint.
By default, the document is available at:
/openapi/v1.json
In .NET 11, the generated document uses OpenAPI 3.2 by default.
Step 3. Explicitly Configure the OpenAPI Version
Although .NET 11 uses OpenAPI 3.2 by default, explicitly configuring the version makes the application's intention clear.
using Microsoft.OpenApi;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi(options =>
{
options.OpenApiVersion = OpenApiSpecVersion.OpenApi3_2;
});
var app = builder.Build();
app.MapOpenApi();
app.Run();
This configuration tells ASP.NET Core to generate an OpenAPI 3.2 document.
Explicit configuration is useful when maintaining multiple API projects because developers can identify the intended specification version without relying on framework defaults.
Maintaining Compatibility With Existing Clients
One of the safest approaches is to keep the existing OpenAPI version until all downstream consumers are ready for the newer format.
For example, an application upgraded to .NET 11 can continue generating an OpenAPI 3.1 document.
using Microsoft.OpenApi;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi(options =>
{
options.OpenApiVersion = OpenApiSpecVersion.OpenApi3_1;
});
var app = builder.Build();
app.MapOpenApi();
app.Run();
This allows the application to use the newer ASP.NET Core framework while retaining the previous documentation format.
It is particularly useful when:
- Existing client-generation tools do not support OpenAPI 3.2.
- External partners depend on the existing specification.
- API management platforms require additional time for compatibility updates.
- The organization needs to upgrade applications gradually.
An important distinction is that keeping OpenAPI 3.1 does not automatically preserve every detail of an earlier generated document. Framework upgrades can introduce changes in schema generation and metadata. Therefore, compare the generated documents before deploying the upgrade.
Supporting Multiple OpenAPI Documents
In larger applications, different consumers may have different compatibility requirements.
Instead of immediately replacing the existing document, you can generate multiple named OpenAPI documents.
For example, one document can target OpenAPI 3.1 for existing consumers, while another targets OpenAPI 3.2 for newer integrations.
using Microsoft.OpenApi;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi("legacy", options =>
{
options.OpenApiVersion = OpenApiSpecVersion.OpenApi3_1;
});
builder.Services.AddOpenApi("modern", options =>
{
options.OpenApiVersion = OpenApiSpecVersion.OpenApi3_2;
});
var app = builder.Build();
app.MapOpenApi();
app.Run();
The documents can be accessed through separate endpoints:
/openapi/legacy.json
/openapi/modern.json
This provides a migration path without immediately forcing every consumer to update its tooling.
However, generating two documents does not automatically create two different API implementations. Both documents describe the application's endpoints unless you configure document-specific filtering or transformations.
You should also ensure that both documents accurately represent the same underlying API behavior.
Understanding What OpenAPI 3.2 Adds
OpenAPI 3.2 includes capabilities that help describe API patterns more accurately.
Some important improvements include:
| Feature |
Purpose |
Practical application |
| HTTP QUERY method |
Describes QUERY operations |
APIs that need query semantics beyond traditional GET requests |
| Server-Sent Events |
Describes streaming responses |
Live notifications and event updates |
| Improved binary schemas |
Describes file and binary responses more accurately |
File downloads and content streaming |
| Improved schema capabilities |
Provides more expressive API descriptions |
Complex request and response models |
| Enhanced API descriptions |
Improves documentation for modern HTTP patterns |
More accurate client and integration tooling |
These capabilities are useful, but upgrading the specification does not automatically introduce them into an application.
For example, an existing API that returns JSON customer information will continue returning JSON unless its implementation changes.
The OpenAPI document describes what the application actually supports. It should not advertise functionality that the application has not implemented.
Testing OpenAPI Documents Before Deployment
Generating an OpenAPI document successfully does not guarantee that every existing consumer can use it.
A compatibility test should be part of the upgrade process.
Step 1. Generate the Document
Generate the OpenAPI document during the build process or retrieve it from the running application.
For build-time generation, ASP.NET Core supports the Microsoft.Extensions.ApiDescription.Server package.
This makes it possible to validate the generated document without depending entirely on a running application.
Step 2. Validate the Specification
Use an OpenAPI-compatible validator to check whether the document follows the selected specification version.
Verify that the document contains the expected paths, schemas, response codes, and security definitions.
Step 3. Compare With the Existing Document
Keep the previously approved OpenAPI document under source control.
Compare the old and new documents to identify changes in:
- Endpoint paths and HTTP methods.
- Request and response schemas.
- Required and optional properties.
- Authentication requirements.
- Response status codes.
- Supported media types.
A documentation change may appear harmless but can affect generated client models.
For example, changing a response property from optional to required can cause generated clients to behave differently.
Step 4. Test Existing Client Generation
Use the same client-generation tools currently used by frontend applications, mobile applications, and external integrations.
Verify that they can import the new document and generate compatible client code.
Do not assume that a document accepted by one tool will automatically work with every other tool.
Advantages and Disadvantages of Upgrading to OpenAPI 3.2
Advantages
- Better support for modern API patterns: OpenAPI 3.2 provides improved descriptions for streaming and newer HTTP operations.
- More accurate API documentation: Improved schema support helps describe different response types and content formats.
- Better integration opportunities: Newer tools can take advantage of capabilities available in the updated specification.
- Improved API development: Teams can describe more complex API behaviors through a standardized document.
- Gradual migration support: ASP.NET Core allows developers to target an earlier specification version when necessary.
Disadvantages
- Tool compatibility: Older client generators and API management platforms may not support OpenAPI 3.2.
- Migration effort: Teams may need to update validation tools, documentation pipelines, and client-generation workflows.
- Document differences: Framework upgrades can change generated schemas even when application endpoints remain unchanged.
- Additional maintenance: Supporting multiple OpenAPI documents introduces more configuration and testing responsibilities.
- Dependency compatibility: Changes in Microsoft.OpenApi versions can introduce breaking changes for applications using related libraries directly.
Best Practices for Updating OpenAPI in Production
Keep the API Contract Separate From the Specification Version
Changing from OpenAPI 3.1 to 3.2 should not automatically require changing API endpoints or response models.
Treat the documentation upgrade and API contract changes as separate activities.
Maintain a Version-Controlled OpenAPI Document
Keep generated documents or approved contract snapshots in source control.
This makes it easier to identify unexpected changes during framework upgrades.
Check Dependency Compatibility
Review the compatibility requirements of Microsoft.AspNetCore.OpenApi, Microsoft.OpenApi, and any additional OpenAPI tooling.
Do not upgrade major package versions without reviewing their migration requirements.
Test All API Consumers
Include frontend applications, mobile applications, external integrations, and API management systems in the compatibility testing process.
Avoid Exposing Internal API Documents Unnecessarily
Generated OpenAPI documents can reveal endpoint names, request structures, and internal implementation details.
Control access to internal API documentation through appropriate environment and authorization settings.
Common Mistakes and Troubleshooting
| Problem |
Possible reason |
Recommended solution |
| OpenAPI document is not generated |
OpenAPI services or endpoint mapping are missing |
Register AddOpenApi and MapOpenApi |
| Existing client generation fails |
Client generator does not support OpenAPI 3.2 |
Generate an OpenAPI 3.1 document temporarily |
| Package upgrade introduces compilation errors |
Incompatible Microsoft.OpenApi major version |
Review dependency compatibility and migration guidance |
| Generated schema changes unexpectedly |
Framework or serializer behavior changed |
Compare the old and new documents |
| Multiple documents contain identical content |
No document-specific configuration is applied |
Configure document-specific transformers or filtering |
| API documentation exposes internal endpoints |
Document is publicly accessible |
Restrict access using environment or authorization policies |
Summary
Updating OpenAPI documentation is an important part of maintaining modern ASP.NET Core applications. OpenAPI 3.2 introduces better support for modern HTTP operations, streaming responses, and more accurate API descriptions.
However, adopting the newer specification should not create unnecessary problems for existing API consumers.
ASP.NET Core allows developers to explicitly select an OpenAPI version and generate multiple named documents when different consumers have different requirements.
The safest migration strategy is to keep the existing API contract stable, validate generated documents, test client-generation tools, and upgrade consumers gradually.
By treating OpenAPI specification updates as a compatibility exercise rather than a simple framework configuration change, development teams can adopt newer documentation capabilities while keeping existing integrations reliable.
Join the conversation! Your thoughts help the community grow.