diff --git a/Directory.Packages.props b/Directory.Packages.props index 9c4dc50e34..fb15b55a50 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -11,7 +11,8 @@ - + + diff --git a/docs/en/API/API-Versioning.md b/docs/en/API/API-Versioning.md index d0f94f2259..741eafbb75 100644 --- a/docs/en/API/API-Versioning.md +++ b/docs/en/API/API-Versioning.md @@ -8,11 +8,10 @@ ABP Framework integrates the [ASPNET-API-Versioning](https://github.com/dotnet/a ```cs public override void ConfigureServices(ServiceConfigurationContext context) { + // Show neutral/versionless APIs. + context.Services.AddTransient(); context.Services.AddAbpApiVersioning(options => { - // Show neutral/versionless APIs. - options.UseApiBehavior = false; - options.ReportApiVersions = true; options.AssumeDefaultVersionWhenUnspecified = true; }); @@ -239,11 +238,10 @@ public override void ConfigureServices(ServiceConfigurationContext context) preActions.Configure(options); }); + // Show neutral/versionless APIs. + context.Services.AddTransient(); context.Services.AddAbpApiVersioning(options => { - // Show neutral/versionless APIs. - options.UseApiBehavior = false; - options.ReportApiVersions = true; options.AssumeDefaultVersionWhenUnspecified = true; @@ -263,27 +261,22 @@ public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context) { + // Show neutral/versionless APIs. + context.Services.AddTransient(); context.Services.AddAbpApiVersioning(options => { - // Show neutral/versionless APIs. - options.UseApiBehavior = false; - options.ReportApiVersions = true; options.AssumeDefaultVersionWhenUnspecified = true; + }).AddApiExplorer(options => { + // add the versioned api explorer, which also adds IApiVersionDescriptionProvider service + // note: the specified format code will format the version as "'v'major[.minor][-status]" + options.GroupNameFormat = "'v'VVV"; + + // note: this option is only necessary when versioning by url segment. the SubstitutionFormat + // can also be used to control the format of the API version in route templates + options.SubstituteApiVersionInUrl = true; }); - context.Services.AddVersionedApiExplorer( - options => - { - // add the versioned api explorer, which also adds IApiVersionDescriptionProvider service - // note: the specified format code will format the version as "'v'major[.minor][-status]" - options.GroupNameFormat = "'v'VVV"; - - // note: this option is only necessary when versioning by url segment. the SubstitutionFormat - // can also be used to control the format of the API version in route templates - options.SubstituteApiVersionInUrl = true; - }); - context.Services.AddTransient, ConfigureSwaggerOptions>(); context.Services.AddAbpSwaggerGen( @@ -322,7 +315,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex app.UseAbpRequestLocalization(); app.UseSwagger(); - app.UseSwaggerUI( + app.UseAbpSwaggerUI( options => { var provider = app.ApplicationServices.GetRequiredService(); diff --git a/docs/zh-Hans/API/API-Versioning.md b/docs/zh-Hans/API/API-Versioning.md index 81bb6574c6..3e63ec045e 100644 --- a/docs/zh-Hans/API/API-Versioning.md +++ b/docs/zh-Hans/API/API-Versioning.md @@ -7,11 +7,10 @@ ABP框架集成了[ASPNET-API-版本控制](https://github.com/dotnet/aspnet-api ```cs public override void ConfigureServices(ServiceConfigurationContext context) { + // Show neutral/versionless APIs. + context.Services.AddTransient(); context.Services.AddAbpApiVersioning(options => { - // Show neutral/versionless APIs. - options.UseApiBehavior = false; - options.ReportApiVersions = true; options.AssumeDefaultVersionWhenUnspecified = true; }); @@ -238,11 +237,10 @@ public override void ConfigureServices(ServiceConfigurationContext context) preActions.Configure(options); }); + // Show neutral/versionless APIs. + context.Services.AddTransient(); context.Services.AddAbpApiVersioning(options => { - // Show neutral/versionless APIs. - options.UseApiBehavior = false; - options.ReportApiVersions = true; options.AssumeDefaultVersionWhenUnspecified = true; @@ -262,27 +260,22 @@ public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context) { + // Show neutral/versionless APIs. + context.Services.AddTransient(); context.Services.AddAbpApiVersioning(options => { - // Show neutral/versionless APIs. - options.UseApiBehavior = false; - options.ReportApiVersions = true; options.AssumeDefaultVersionWhenUnspecified = true; + }).AddApiExplorer(options => { + // add the versioned api explorer, which also adds IApiVersionDescriptionProvider service + // note: the specified format code will format the version as "'v'major[.minor][-status]" + options.GroupNameFormat = "'v'VVV"; + + // note: this option is only necessary when versioning by url segment. the SubstitutionFormat + // can also be used to control the format of the API version in route templates + options.SubstituteApiVersionInUrl = true; }); - context.Services.AddVersionedApiExplorer( - options => - { - // add the versioned api explorer, which also adds IApiVersionDescriptionProvider service - // note: the specified format code will format the version as "'v'major[.minor][-status]" - options.GroupNameFormat = "'v'VVV"; - - // note: this option is only necessary when versioning by url segment. the SubstitutionFormat - // can also be used to control the format of the API version in route templates - options.SubstituteApiVersionInUrl = true; - }); - context.Services.AddTransient, ConfigureSwaggerOptions>(); context.Services.AddAbpSwaggerGen( @@ -321,7 +314,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex app.UseAbpRequestLocalization(); app.UseSwagger(); - app.UseSwaggerUI( + app.UseAbpSwaggerUI( options => { var provider = app.ApplicationServices.GetRequiredService(); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/Extensions/DependencyInjection/AbpApiVersioningExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/Extensions/DependencyInjection/AbpApiVersioningExtensions.cs index c3f93fc06c..ac841bb5f8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/Extensions/DependencyInjection/AbpApiVersioningExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Microsoft/Extensions/DependencyInjection/AbpApiVersioningExtensions.cs @@ -11,7 +11,7 @@ namespace Microsoft.Extensions.DependencyInjection; public static class AbpApiVersioningExtensions { - public static IServiceCollection AddAbpApiVersioning( + public static IApiVersioningBuilder AddAbpApiVersioning( this IServiceCollection services, Action? apiVersioningOptionsSetupAction = null, Action? mvcApiVersioningOptionsSetupAction = null) @@ -21,9 +21,7 @@ public static class AbpApiVersioningExtensions apiVersioningOptionsSetupAction ??= _ => { }; mvcApiVersioningOptionsSetupAction ??= _ => { }; - services.AddApiVersioning(apiVersioningOptionsSetupAction).AddMvc(mvcApiVersioningOptionsSetupAction); - - return services; + return services.AddApiVersioning(apiVersioningOptionsSetupAction).AddMvc(mvcApiVersioningOptionsSetupAction); } public static void ConfigureAbp(this MvcApiVersioningOptions options, AbpAspNetCoreMvcOptions mvcOptions) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj index c52ec08b2a..a6e2edc2cf 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo.Abp.AspNetCore.Mvc.csproj @@ -32,6 +32,7 @@ +