I'm looking into .net core 6, API versioning and trying to show two versions "v1" and "v2" in swagger UI but only "v1" is showing though no error is appearing .
Here is my program.cs code
builder.Services.AddApiVersioning(setup =>
{
setup.DefaultApiVersion = new ApiVersion(1,0);
setup.AssumeDefaultVersionWhenUnspecified = true;
setup.ReportApiVersions = true;
});
builder.Services.AddVersionedApiExplorer(setup =>
{
setup.GroupNameFormat = "'v'VVV";
setup.SubstituteApiVersionInUrl = true;
});
builder.Services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "API",
Description = "An API in dotnet core 6",
});
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
options.IncludeXmlComments(Path.Combine($@"{AppContext.BaseDirectory}", xmlFilename));
});
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
v1 controller have this action method
[MapToApiVersion("1.0")]
[HttpGet]
[Route("GetLast12MonthBalances")]
public async Task<ApiResponse> GetLast12MonthBalances()
{
v2 controller have this action method
[MapToApiVersion("2.0")]
[HttpGet,Route("GetLast12MonthBalances")]
public async Task<ApiResponse> GetLast12MonthBalances()
{
Any idea what is missing ?