Visual Studio 2022 - how to to Configure API Versioning with Swashbuckle in ASP.NET Core 7.0
I'm trying to debug I'm currently trying to set up API versioning in my ASP.NET Core 7.0 project using Swashbuckle for Swagger documentation in Visual Studio 2022. I followed the official documentation, but I'm running into an scenario where the generated Swagger documentation does not reflect the different API versions I defined. I added the necessary NuGet packages for both `Microsoft.AspNetCore.Mvc.Versioning` and `Swashbuckle.AspNetCore`, and configured them in `Startup.cs` like so: ```csharp public void ConfigureServices(IServiceCollection services) { services.AddApiVersioning(options => { options.AssumeDefaultVersionWhenUnspecified = true; options.DefaultApiVersion = new ApiVersion(1, 0); options.ReportApiVersions = true; }); services.AddVersionedApiExplorer(options => { options.GroupNameFormat = "v{version:apiVersion}"; options.SubstituteApiVersionInUrl = true; }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" }); c.SwaggerDoc("v2", new OpenApiInfo { Title = "My API", Version = "v2" }); }); } ``` And in my controller, I'm using the `ApiVersion` attribute: ```csharp [ApiVersion("1.0")] [ApiVersion("2.0")] [Route("api/v{version:apiVersion}/[controller]")] [ApiController] public class MyController : ControllerBase { [HttpGet] public IActionResult Get() => Ok("Hello, World!"); } ``` However, when I run the application and navigate to `/swagger`, I only see the `v1` endpoint listed, and there's no sign of the `v2` endpoint. I’ve also tried cleaning and rebuilding the solution, but that didn't help. Is there something I’m missing in the configuration that would cause the API versioning not to work as expected? The console output does not show any errors related to Swagger or versioning, so I'm unsure if the scenario lies in my setup or elsewhere. What's the correct way to implement this?