Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Migration from Microsoft.AspNetCore.Mvc.Versioning to Asp.Versioning.Mvc causes versioning to no longer work #917

Copy link
Copy link
Closed
@ustarrenato

Description

@ustarrenato
Issue body actions

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Hi,

We are currently in a process of migrating our codebase to .NET 6, and we noticed we no longer could get versioning to work.

I have successfully recreated the issue in a new .NET 6 ASP.NET Core project, and was able to confirm that using Microsoft.AspNetCore.Mvc.Versioning (5.0.0) and AddVersionedApiExplorer, IApiVersionDescriptionProvider works as expected.

This means that IApiVersionDescriptionProvider is able to pick up two versions specified in a versioned controller, and this can then be passed to Swagger UI.

Using Asp.Versioning.Mvc.ApiExplorer (6.2.1, 6.2.0, 6.0.0) and AddApiExplorer causes IApiVersionDescriptionProvider to only show default API version (defaulting to 1.0 when not specified) and does not register any versioning applied to the versioned controller.

I have included link to a solution containing two projects, one which uses the latest Microsoft.AspNetCore.Mvc.Versioning at the time of writing (5.0.0), and one that uses the latest Asp.Versioning.Mvc (6.2.1).

I would kindly ask to confirm if this is indeed the BUG, or am I simply missing something in the configuration.

I should also note InfoController is simply added to test that endpoints are mapped correctly, and is not used as a part of versioning (And the issue persists even if the controller is removed).

image
image

Expected Behavior

After successful build, both projects should be able to display swagger UI with two versions, 2.0 and 3.0.

Steps To Reproduce

Link to repo:

https://github.com/ustarrenato/WebAppWithVersioning

Setting the breakpointing in Program.cs line 70 in VS shows that apiVersionDescriptionProvider?.ApiVersionDescriptions has only one version in WebAppWithVersioning (1.0) while WebAppWithVersioningMicrosoft5 has two (2.0, 3.0).

Exceptions (if any)

No response

.NET Version

7.0.100

Anything else?

Microsoft.NETCore.App 6.0.11
Visual Studio 2022 Version 17.4.0
Microsoft .NET Framework 4.8.09037
ASP.NET and Web Tools 17.4.326.54890
Swagger 6.4.0

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.