MireaBackend/Endpoint/Configuration/Core/Startup/ApiVersioningConfiguration.cs

22 lines
759 B
C#
Raw Normal View History

2024-09-18 06:00:07 +03:00
using Asp.Versioning;
using Microsoft.Extensions.DependencyInjection;
2024-10-07 02:13:35 +03:00
namespace Mirea.Api.Endpoint.Configuration.Core.Startup;
public static class ApiVersioningConfiguration
{
public static IApiVersioningBuilder AddCustomApiVersioning(this IServiceCollection services)
{
return services.AddApiVersioning(options =>
{
options.DefaultApiVersion = new ApiVersion(1, 0);
options.AssumeDefaultVersionWhenUnspecified = true;
options.ReportApiVersions = true;
options.ApiVersionReader = new UrlSegmentApiVersionReader();
2024-09-18 06:00:07 +03:00
}).AddApiExplorer(options =>
{
options.GroupNameFormat = "'v'VVV";
options.SubstituteApiVersionInUrl = true;
});
}
}