Skip to content

Microsoft.Extensions.ApiDescription.Server should allow setting the complete filename #63049

@jscarle

Description

@jscarle

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

No one assigned

    Labels

    area-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIfeature-openapi

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions