Skip to content

Setting the OpenAPI spec version not working #64397

@Zylvian

Description

@Zylvian

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

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;
});

BackendService.csproj:

  <PropertyGroup>
    <OpenApiDocumentsDirectory>.</OpenApiDocumentsDirectory>
  </PropertyGroup>
  <ItemGroup>
    <OpenApiGenerateDocumentsOptions Include="Options">
      <Options>--openapi-version OpenApi3_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"
  }

Any suggestions gladly appreciated!

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

.NET 10

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions