Skip to content

New WithOpenApi() methods breaks ASP.NET API Versioning #920

Closed
@joaofbantunes

Description

@joaofbantunes

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When using the new WithOpenApi() methods, from the Microsoft.AspNetCore.OpenApi package, ASP.NET API Versioning seems to be affected and some features misbehave.

A couple of examples I've noticed:

  1. The name passed in MapApiGroup isn't used to group the endpoints in the Swagger UI
  2. Non-deprecated version is shown as deprecated

A couple of visual examples:

image
image

Expected Behavior

ASP.NET API Versioning features working the same, regardless of WithOpenApi usage.

Steps To Reproduce

To reproduce, all I did was use the MinimalOpenApiExample available in the examples, then:

  • Added the Microsoft.AspNetCore.OpenApi package:
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.0" />
  • Called WithOpenApi in one of the endpoints:
ordersV1.MapGet( "/{id:int}", ( int id ) => new OrderV1() { Id = id, Customer = "John Doe" } )
    .WithOpenApi()
    .Produces<OrderV1>()
    .Produces( 404 );

Complete repro example: https://github.com/joaofbantunes/AspNetApiVersioningWithOpenApiRepro

Exceptions (if any)

No response

.NET Version

7.0.100

Anything else?

Apologies if it's "too soon", as I'm reporting this while testing with ASP.NET API Versioning 7.0.0-preview.2, and maybe you're aware of the issue just haven't got to it yet. Just in case, as I was testing, thought of reporting.

Also, not sure if this is something fixable here, or misbehavior of Microsoft.AspNetCore.OpenApi?

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions