aspnet-api-versioning icon indicating copy to clipboard operation
aspnet-api-versioning copied to clipboard

Do we have any samples about how to generate OpenAPI documents with ApiVersion and Group

Open SamGuoMsft opened this issue 8 months ago • 1 comments
trafficstars

Is there an existing issue for this?

  • [x] I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Do we have any samples about how to generate OpenAPI documents with ApiVersion and Group?

Describe the solution you'd like

Hope can see some samples like Swagger samples that show how to generate Open API document with ApiVersion and Group.

Additional context

No response

SamGuoMsft avatar Feb 27 '25 06:02 SamGuoMsft

I am looking for the same thing. I can only find an example using swagger. https://github.com/dotnet/aspnet-api-versioning/blob/main/examples/AspNetCore/WebApi/MinimalOpenApiExample/Program.cs

Is this possible?

runxc1 avatar Mar 10 '25 14:03 runxc1

Just having

services
         .AddOpenApi("v1)
        .AddOpenApi("v2)
        .AddApiVersioning(opt => {
            opt.ReportApiVersions = true;
        }).AddApiExplorer(options => {
            options.GroupNameFormat = "'v'VVV";
        });

//app init
app.MapOpenApi();

Makes both v1 and v2 documents available and with the correct looking structures

spaasis avatar Jul 10 '25 13:07 spaasis