Closed AleksandarDevic closed 3 months ago
My fault. Everyting works.
public static class DependencyInjection { public static IServiceCollection AddInfrastructure( this IServiceCollection services, IConfiguration configuration) { AddApiVersioning(services);
return services;
}
private static void AddApiVersioning(IServiceCollection services)
{
services
.AddApiVersioning(options =>
{
options.DefaultApiVersion = new ApiVersion(1);
options.ReportApiVersions = true;
options.ApiVersionReader = new UrlSegmentApiVersionReader();
})
.AddMvc()
.AddApiExplorer(options =>
{
options.GroupNameFormat = "'v'VVV";
options.SubstituteApiVersionInUrl = true;
});
}
}
With new template(webapi) in .NET9 - ASP.NET Core Swagger build-in is removed.
Can anyone show me/help me how to implement API versioning using Microsoft OpenApi with minimal-api.
Some part of configuration is: ApiVersionSet apiVersionSet = app.NewApiVersionSet() .HasApiVersion(new ApiVersion(1)) .ReportApiVersions() .Build();
var routeGroupBuilder = app.MapGroup("api/v{version:apiVersion}").WithApiVersionSet(apiVersionSet);
Thanks in advance. :-)