27 lines
858 B
C#
27 lines
858 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Versioning;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Mirea.Api.Endpoint.Configuration.AppConfig;
|
|
|
|
public static class ApiVersioningConfiguration
|
|
{
|
|
public static void AddCustomApiVersioning(this IServiceCollection services)
|
|
{
|
|
services.AddApiVersioning(options =>
|
|
{
|
|
options.DefaultApiVersion = new ApiVersion(1, 0);
|
|
options.AssumeDefaultVersionWhenUnspecified = true;
|
|
options.ReportApiVersions = true;
|
|
options.ApiVersionReader = new UrlSegmentApiVersionReader();
|
|
});
|
|
|
|
services.AddVersionedApiExplorer(options =>
|
|
{
|
|
options.GroupNameFormat = "'v'VVV";
|
|
options.SubstituteApiVersionInUrl = true;
|
|
});
|
|
|
|
services.AddEndpointsApiExplorer();
|
|
}
|
|
} |