Allow C# Microsoft.Extensions.ApiDescription.Server package to generate 3.0.x OpenAPI specifications on Build

Eric Fitskie 116 Reputation points
2026-06-24T08:53:01.88+00:00

I'm using the Microsoft.Extensions.ApiDescription.Server 10.0.0.9 nuget package to generate the OpenAPI specification on build of my project. This always generate an 3.1.1 OpenAPI spec version document.

I need to import this OpenAPI spec in Azure API Management, but unfortunately the generated OpenAPI 3.1.1 is not supported in the API Management import.

The issue in api-management-developer-portal for support for 3.1.1. versions (https://github.com/Azure/api-management-developer-portal/issues/2839) is still open for a long time.

Please let me chose the version of the OpenAPI spec that is generated on Build of my C# project so I can import this file in Azure API Management.

Developer technologies | ASP.NET Core | ASP.NET API
0 comments No comments

Answer accepted by question author
Danny Nguyen (WICLOUD CORPORATION) 8,725 Reputation points Microsoft External Staff Moderator
2026-06-24T10:01:13.53+00:00

Hi @Eric Fitskie ,

For build-time generation with Microsoft.Extensions.ApiDescription.Server, the OpenAPI version should be set through the MSBuild option OpenApiGenerateDocumentsOptions, not only through AddOpenApi() in code.

For example, in the .csproj file:

<PropertyGroup>
  <OpenApiGenerateDocuments>true</OpenApiGenerateDocuments>
  <OpenApiGenerateDocumentsOnBuild>true</OpenApiGenerateDocumentsOnBuild>
  <OpenApiGenerateDocumentsOptions>--openapi-version OpenApi3_0</OpenApiGenerateDocumentsOptions>
</PropertyGroup>

I tested this with an ASP.NET Core Web API project using Microsoft.Extensions.ApiDescription.Server 10.0.9. With --openapi-version OpenApi3_0, the build-time generated document started with "3.0.4"

When changing it to OpenApi3_1, it generated the 3.1 document as expected.

So for your case, please try adding --openapi-version OpenApi3_0 to OpenApiGenerateDocumentsOptions. The ASP.NET Core OpenAPI documentation also mentions that build-time generation can select the OpenAPI version through this MSBuild option: Generate OpenAPI documents

One thing to note, Azure API Management has limitations around OpenAPI 3.1 support, so generating a 3.0.x document is the safer path for APIM import: API import restrictions and known issues

If you found my response helpful or informative, I would greatly appreciate it if you could follow this guidance or provide feedback.

Thank you. 

Was this answer helpful?

2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.