© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3mo ago•
1 reply
Zylvian

ASP.NET: setting the OpenAPI spec version not working

I'm trying to set the OpenAPI spec version to 3.0 for the time being, yet neither the delegate method nor the MSBuild method proposed in the docs are working.

I need it as 3.0 for the correct OpenAPI.json file to be generated, and have tried this:

Program.cs:
builder.Services.AddOpenApi(options =>
{
    options.OpenApiVersion = OpenApiSpecVersion.OpenApi3_0;
});
builder.Services.AddOpenApi(options =>
{
    options.OpenApiVersion = OpenApiSpecVersion.OpenApi3_0;
});


BackendService.csproj:
  <PropertyGroup>
    <OpenApiDocumentsDirectory>.</OpenApiDocumentsDirectory>
  </PropertyGroup>
  <ItemGroup>
    <OpenApiGenerateDocumentsOptions Include="Options">
      <Options>--openapi-version OpenApi2_0</Options>
    </OpenApiGenerateDocumentsOptions>
  </ItemGroup>
  <PropertyGroup>
    <OpenApiDocumentsDirectory>.</OpenApiDocumentsDirectory>
  </PropertyGroup>
  <ItemGroup>
    <OpenApiGenerateDocumentsOptions Include="Options">
      <Options>--openapi-version OpenApi2_0</Options>
    </OpenApiGenerateDocumentsOptions>
  </ItemGroup>


Yet the generated OpenAPI.json is always version 3.1:
OpenAPI.json:
  "openapi": "3.1.1",
  "info": {
    "title": "BackendService | v1",
    "version": "1.0.0"
  }
  "openapi": "3.1.1",
  "info": {
    "title": "BackendService | v1",
    "version": "1.0.0"
  }


Any suggestions gladly appreciated!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Normalizing OpenApi Spec File
C#CC# / help
2y ago
✅ ASP.NET Core SSL not working.
C#CC# / help
2y ago
[ASP.NET] Docker build not working properly.
C#CC# / help
2y ago
❔ asp.net mvc database connection not working
C#CC# / help
3y ago