dotnet / dotnet/aspnetcore

Setting the OpenAPI spec version not working

Open
#64,397 8 comments 2 reactions 0 assignees View on GitHub
area-minimal feature-openapi
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [x] 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:**
```cs
builder.Services.AddOpenApi(options =>
{
options.OpenApiVersion = OpenApiSpecVersion.OpenApi3_0;
});
```

**BackendService.csproj:**
```cs

.



--openapi-version OpenApi3_0


```

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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.