https://github.com/thygesteffensen/openapiminimal
Minimal reproducable example of build-time OpenAPI spec generation not using configured options
https://github.com/thygesteffensen/openapiminimal
Last synced: about 1 month ago
JSON representation
Minimal reproducable example of build-time OpenAPI spec generation not using configured options
- Host: GitHub
- URL: https://github.com/thygesteffensen/openapiminimal
- Owner: thygesteffensen
- Created: 2025-02-18T14:31:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-18T14:55:35.000Z (over 1 year ago)
- Last Synced: 2025-02-18T15:28:15.614Z (over 1 year ago)
- Language: C#
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Minimalistic reproduction of build-time generated OpenAPI document version bug
This is to show that build-time OpenAPI document generation does not follow configured options as described in https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/aspnetcore-openapi?view=aspnetcore-9.0&tabs=visual-studio#lint-generated-openapi-documents-with-spectral.
This example is created by using the Microsoft WebApi template:
1. `dotnet new webapi -n WebApi -minimal`
2. Configure OpenAPI version to be $2.0$: `options.OpenApiVersion = OpenApiSpecVersion.OpenApi2_0;` in `.AddOpenApi()`.
3. Add the `Microsoft.Extensions.ApiDescription.Server` NuGet package to emit OpenAPI document on build.
## Steps to reproduce
1. Clone repository.
2. Run `dotnet build`.
3. Open `~/WebApi/obj/WebApi.json` (OpenAPI document generated at build), it is in version $3.0$. (It should be in V2, as configured)
4. Run `dotnet run`.
5. Execute `GET {{WebApi_HostAddress}}/openapi/v1.json` form `WebApi.http`, document is in version $2.0$.
## Environment
```
$ dotnet --version
9.0.200
```
Apple M2 Pro - Sequoia 15.3