-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Open
Open
Copy link
Labels
area-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIfeature-openapi
Milestone
Description
Microsoft.Extensions.ApiDescription.Server allows build-time generation of OpenAPI documents, but as per the documentation:
If multiple documents are registered, and document name is not v1, it's post-fixed with the document name. E.g., {ProjectName}_{DocumentName}.json.
There is an option to set the filename:
<PropertyGroup>
<OpenApiGenerateDocumentsOptions>--file-name my-open-api</OpenApiGenerateDocumentsOptions>
</PropertyGroup>
But this does not set the filename, only the project name prefix. If your document name is not v1
, the --file-name
parameters only sets the prefix. My document name, for example is openapi.json
, using the above, I end up with my-filename_openapi.json
.
So if I want to match my OpenAPI endpoint configuration below:
var builder = WebApplication.CreateBuilder(args);
services.AddOpenApi("openapi");
var app = builder.Build();
app.MapOpenApi("/{documentName}.json");
app.Run();
There's simply no way and requires me to run a post-build script to rename the output file.
Metadata
Metadata
Assignees
Labels
area-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIfeature-openapi