From d655a65d5e2b2d98b8fe24c019a34663efbb5c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 4 Oct 2017 11:35:13 +0300 Subject: [PATCH] Add IsApiVersionNeutral only if not defined ApiVersionAttribute. --- .../AbpApiVersioningOptionsExtensions.cs | 12 ++++++++---- .../Volo/Abp/Identity/FixtureController.cs | 16 ++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Volo.Abp.AspNetCore.Mvc/Microsoft/Extensions/DependencyInjection/AbpApiVersioningOptionsExtensions.cs b/src/Volo.Abp.AspNetCore.Mvc/Microsoft/Extensions/DependencyInjection/AbpApiVersioningOptionsExtensions.cs index 689b378255..372b216583 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Microsoft/Extensions/DependencyInjection/AbpApiVersioningOptionsExtensions.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Microsoft/Extensions/DependencyInjection/AbpApiVersioningOptionsExtensions.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Reflection; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Versioning; using Microsoft.AspNetCore.Mvc.Versioning.Conventions; using Volo.Abp.AspNetCore.Mvc; @@ -53,10 +54,13 @@ namespace Microsoft.Extensions.DependencyInjection } else { - typeof(ControllerApiVersionConventionBuilder<>) - .MakeGenericType(controllerType) - .GetMethod("IsApiVersionNeutral") - .Invoke(controllerBuilder, null); + if (!controllerType.IsDefined(typeof(ApiVersionAttribute), true)) + { + typeof(ControllerApiVersionConventionBuilder<>) + .MakeGenericType(controllerType) + .GetMethod("IsApiVersionNeutral") + .Invoke(controllerBuilder, null); + } } } } diff --git a/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/FixtureController.cs b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/FixtureController.cs index eca154f6ab..74d831e65e 100644 --- a/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/FixtureController.cs +++ b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/FixtureController.cs @@ -10,22 +10,22 @@ namespace Volo.Abp.Identity [Route("api/v{api-version:apiVersion}/identity/fixture")] public class FixtureController : AbpController, IRemoteService { - [HttpGet] + [HttpGet, MapToApiVersion("2.0")] public int Get() { - return 42; + return 41; } - //[HttpGet, MapToApiVersion("3.0")] - //public int Get3() - //{ - // return 42; - //} + [HttpGet, MapToApiVersion("3.0")] + public int Get3() + { + return 42; + } [HttpPost] public int Post() { - return 42; + return 43; } } } \ No newline at end of file