diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs index e41fa04806..8368b2e9d0 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs @@ -66,7 +66,7 @@ namespace Volo.Abp.AspNetCore.Mvc var moduleModel = model.GetOrAddModule(GetRootPath(controllerType, setting)); - var controllerModel = moduleModel.GetOrAddController(CalculateControllerName(controllerType, setting), controllerType, _modelOptions.IgnoredInterfaces); + var controllerModel = moduleModel.GetOrAddController(controllerType.FullName, CalculateControllerName(controllerType, setting), controllerType, _modelOptions.IgnoredInterfaces); var method = apiDescription.ActionDescriptor.GetMethodInfo(); @@ -77,9 +77,8 @@ namespace Volo.Abp.AspNetCore.Mvc return; } - var actionModel = controllerModel.AddAction(ActionApiDescriptionModel.Create( + var actionModel = controllerModel.AddAction(uniqueMethodName, ActionApiDescriptionModel.Create( method, - uniqueMethodName, apiDescription.RelativePath, apiDescription.HttpMethod )); @@ -101,7 +100,7 @@ namespace Volo.Abp.AspNetCore.Mvc private static string GetUniqueActionName(MethodInfo method) { - var methodNameBuilder = new StringBuilder(method.Name); + var methodNameBuilder = new StringBuilder(method.Name.RemovePostFix("Async")); var parameters = method.GetParameters(); if (parameters.Any()) diff --git a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs index b58e43e1ec..206b55c2a4 100644 --- a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs +++ b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs @@ -35,7 +35,7 @@ namespace Volo.Abp.Http.Client.DynamicProxying foreach (var action in controller.Actions.Values) { - if (action.NameOnClass == method.Name && action.ParametersOnMethod.Count == methodParameters.Length) + if (action.Name == method.Name && action.ParametersOnMethod.Count == methodParameters.Length) { var found = true; diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ActionApiDescriptionModel.cs b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ActionApiDescriptionModel.cs index 75c22621c3..9b93ea792c 100644 --- a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ActionApiDescriptionModel.cs +++ b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ActionApiDescriptionModel.cs @@ -9,9 +9,7 @@ namespace Volo.Abp.Http.Modeling [Serializable] public class ActionApiDescriptionModel { - public string UniqueName { get; set; } - - public string NameOnClass { get; set; } + public string Name { get; set; } public string HttpMethod { get; set; } @@ -28,12 +26,11 @@ namespace Volo.Abp.Http.Modeling } - public static ActionApiDescriptionModel Create(MethodInfo method, string uniqueName, string url, string httpMethod) + public static ActionApiDescriptionModel Create(MethodInfo method, string url, string httpMethod) { return new ActionApiDescriptionModel { - UniqueName = uniqueName, - NameOnClass = method.Name, + Name = method.Name, Url = url, HttpMethod = httpMethod, ReturnValue = ReturnValueApiDescriptionModel.Create(method.ReturnType), diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs index ca9dbb9415..9d7216d357 100644 --- a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs +++ b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs @@ -36,16 +36,16 @@ namespace Volo.Abp.Http.Modeling }; } - public ActionApiDescriptionModel AddAction(ActionApiDescriptionModel action) + public ActionApiDescriptionModel AddAction(string uniqueName, ActionApiDescriptionModel action) { - if (Actions.ContainsKey(action.UniqueName)) + if (Actions.ContainsKey(uniqueName)) { throw new AbpException( - $"Can not add more than one action with same name to the same controller. Controller: {ControllerName}, Action: {action.UniqueName}." - ); + $"Can not add more than one action with same name to the same controller. Controller: {ControllerName}, Action: {action.Name}." + ); } - return Actions[action.UniqueName] = action; + return Actions[uniqueName] = action; } public ControllerApiDescriptionModel CreateSubModel(string[] actions) @@ -58,11 +58,11 @@ namespace Volo.Abp.Http.Modeling Actions = new Dictionary() }; - foreach (var action in Actions.Values) + foreach (var action in Actions) { - if (actions == null || actions.Contains(action.UniqueName)) + if (actions == null || actions.Contains(action.Key)) { - subModel.AddAction(action); + subModel.AddAction(action.Key, action.Value); } } diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs index e776818508..44967fa50c 100644 --- a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs +++ b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs @@ -41,9 +41,9 @@ namespace Volo.Abp.Http.Modeling return Controllers[controller.ControllerName] = controller; } - public ControllerApiDescriptionModel GetOrAddController(string name, Type type, [CanBeNull] HashSet ignoredInterfaces = null) + public ControllerApiDescriptionModel GetOrAddController(string uniqueName, string name, Type type, [CanBeNull] HashSet ignoredInterfaces = null) { - return Controllers.GetOrAdd(name, () => ControllerApiDescriptionModel.Create(name, type, ignoredInterfaces)); + return Controllers.GetOrAdd(uniqueName, () => ControllerApiDescriptionModel.Create(name, type, ignoredInterfaces)); } public ModuleApiDescriptionModel CreateSubModel(string[] controllers, string[] actions) diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/JQuery/JQueryProxyScriptGenerator.cs b/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/JQuery/JQueryProxyScriptGenerator.cs index 299a9855e4..8310d286ed 100644 --- a/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/JQuery/JQueryProxyScriptGenerator.cs +++ b/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/JQuery/JQueryProxyScriptGenerator.cs @@ -73,8 +73,8 @@ namespace Volo.Abp.Http.ProxyScripting.Generators.JQuery { var parameterList = ProxyScriptingJsFuncHelper.GenerateJsFuncParameterList(action, "ajaxParams"); - script.AppendLine($" // action '{action.NameOnClass.ToCamelCase()}'"); - script.AppendLine($" abp.services.{module.RootPath.Replace("/", ".").ToCamelCase()}.{controller.ControllerName.ToCamelCase()}{ProxyScriptingJsFuncHelper.WrapWithBracketsOrWithDotPrefix(action.NameOnClass.RemovePostFix("Async").ToCamelCase())} = function({parameterList}) {{"); + script.AppendLine($" // action '{action.Name.ToCamelCase()}'"); + script.AppendLine($" abp.services.{module.RootPath.Replace("/", ".").ToCamelCase()}.{controller.ControllerName.ToCamelCase()}{ProxyScriptingJsFuncHelper.WrapWithBracketsOrWithDotPrefix(action.Name.RemovePostFix("Async").ToCamelCase())} = function({parameterList}) {{"); script.AppendLine(" return abp.ajax($.extend(true, {"); AddAjaxCallParameters(script, controller, action); diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/ProxyScriptingHelper.cs b/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/ProxyScriptingHelper.cs index c962263bd8..64d1515574 100644 --- a/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/ProxyScriptingHelper.cs +++ b/src/Volo.Abp.Http/Volo/Abp/Http/ProxyScripting/Generators/ProxyScriptingHelper.cs @@ -47,7 +47,7 @@ namespace Volo.Abp.Http.ProxyScripting.Generators if (parameters.Length > 1) { throw new AbpException( - $"Only one complex type allowed as argument to a controller action that's binding source is 'Body'. But {action.UniqueName} ({action.Url}) contains more than one!" + $"Only one complex type allowed as argument to a controller action that's binding source is 'Body'. But {action.Name} ({action.Url}) contains more than one!" ); } diff --git a/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs b/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs index 503cd2189f..bfa67da872 100644 --- a/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs +++ b/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs @@ -9,10 +9,12 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Swashbuckle.AspNetCore.Swagger; using Volo.Abp.AspNetCore.Modularity; +using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Autofac; using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.Identity.EntityFrameworkCore; +using Volo.Abp.Identity.HttpApi.Host.VersioningTests.V1; using Volo.Abp.Modularity; namespace Volo.Abp.Identity.HttpApi.Host @@ -25,8 +27,6 @@ namespace Volo.Abp.Identity.HttpApi.Host var hostingEnvironment = services.GetSingletonInstance(); //TOD: Move to BuildConfiguration method var configuration = BuildConfiguration(hostingEnvironment); - services.AddOptions(); //TODO: Remove later, for test purposes - services.Configure(configuration); services.Configure(options => @@ -88,6 +88,20 @@ namespace Volo.Abp.Identity.HttpApi.Host //options.IncludeXmlComments(XmlCommentsFilePath); //TODO: Add XML comments! }); + services.Configure(options => + { + options.AppServiceControllers.Create(typeof(AbpIdentityHttpApiHostModule).Assembly, o => + { + o.TypePredicate = t => t == typeof(CallsController); + }); + + options.AppServiceControllers.Create(typeof(AbpIdentityHttpApiHostModule).Assembly, o => + { + o.TypePredicate = t => t == typeof(Host.VersioningTests.V2.CallsController); + o.RootPath = "app/compat"; + }); + }); + services.AddAssemblyOf(); } diff --git a/src/Volo.Abp.Identity.HttpApi.Host/Controllers/HomeController.cs b/src/Volo.Abp.Identity.HttpApi.Host/Controllers/HomeController.cs index 3b61831e3f..34283e4d36 100644 --- a/src/Volo.Abp.Identity.HttpApi.Host/Controllers/HomeController.cs +++ b/src/Volo.Abp.Identity.HttpApi.Host/Controllers/HomeController.cs @@ -5,7 +5,6 @@ namespace Volo.Abp.Identity.HttpApi.Host.Controllers { public class HomeController : AbpController { - [HttpPost] public IActionResult Index() { return Redirect("/swagger"); diff --git a/src/Volo.Abp.Identity.HttpApi.Host/VersioningTests/V1/CallsController.cs b/src/Volo.Abp.Identity.HttpApi.Host/VersioningTests/V1/CallsController.cs index 79073d8ba7..5837df2e2b 100644 --- a/src/Volo.Abp.Identity.HttpApi.Host/VersioningTests/V1/CallsController.cs +++ b/src/Volo.Abp.Identity.HttpApi.Host/VersioningTests/V1/CallsController.cs @@ -1,16 +1,16 @@ using System.Collections.Generic; -using System.Linq; using Microsoft.AspNetCore.Mvc; using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; using Volo.Abp.AspNetCore.Mvc; namespace Volo.Abp.Identity.HttpApi.Host.VersioningTests.V1 { [ApiVersion("1.0")] [Route("api/v{api-version:apiVersion}/calls")] - public class CallsController : AbpController + public class CallsController : AbpController, IRemoteService { - private static List _calls = new List + private static readonly List Calls = new List { new CallDto {Id = 1, Number = "123456"}, new CallDto { Id = 2, Number = "123457" } @@ -19,7 +19,7 @@ namespace Volo.Abp.Identity.HttpApi.Host.VersioningTests.V1 [HttpGet] public List GetList() { - return _calls; + return Calls; } } @@ -27,29 +27,4 @@ namespace Volo.Abp.Identity.HttpApi.Host.VersioningTests.V1 { public string Number { get; set; } } - - [ApiVersion("2.0")] - [Route("api/v{api-version:apiVersion}/calls")] - [ControllerName("Calls")] - public class Calls2Controller : AbpController - { - private static List _calls = new List - { - new CallDto {Id = 1, Number = "123456000"}, - new CallDto { Id = 2, Number = "123457000" } - }; - - [HttpGet] - public List GetList() - { - return _calls; - } - - [HttpGet] - [Route("by-filter")] - public List GetList(string num) - { - return _calls.Where(c => c.Number.Contains(num)).ToList(); - } - } } diff --git a/src/Volo.Abp.Identity.HttpApi.Host/VersioningTests/V2/Calls2Controller.cs b/src/Volo.Abp.Identity.HttpApi.Host/VersioningTests/V2/Calls2Controller.cs new file mode 100644 index 0000000000..4a7b908782 --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi.Host/VersioningTests/V2/Calls2Controller.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.Application.Services; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Identity.HttpApi.Host.VersioningTests.V1; + +namespace Volo.Abp.Identity.HttpApi.Host.VersioningTests.V2 +{ + [ApiVersion("2.0")] + [Route("api/v{api-version:apiVersion}/calls")] + public class CallsController : AbpController, IRemoteService + { + private static List _calls = new List + { + new CallDto {Id = 1, Number = "123456000"}, + new CallDto { Id = 2, Number = "123457000" } + }; + + [HttpGet] + public List GetList() + { + return _calls; + } + + [HttpGet] + [Route("by-filter")] + public List GetList(string num) + { + return _calls.Where(c => c.Number.Contains(num)).ToList(); + } + } +} \ No newline at end of file