Browse Source

Add IsApiVersionNeutral only if not defined ApiVersionAttribute.

pull/122/head
Halil İbrahim Kalkan 9 years ago
parent
commit
d655a65d5e
  1. 12
      src/Volo.Abp.AspNetCore.Mvc/Microsoft/Extensions/DependencyInjection/AbpApiVersioningOptionsExtensions.cs
  2. 16
      src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/FixtureController.cs

12
src/Volo.Abp.AspNetCore.Mvc/Microsoft/Extensions/DependencyInjection/AbpApiVersioningOptionsExtensions.cs

@ -1,5 +1,6 @@
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Versioning; using Microsoft.AspNetCore.Mvc.Versioning;
using Microsoft.AspNetCore.Mvc.Versioning.Conventions; using Microsoft.AspNetCore.Mvc.Versioning.Conventions;
using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc;
@ -53,10 +54,13 @@ namespace Microsoft.Extensions.DependencyInjection
} }
else else
{ {
typeof(ControllerApiVersionConventionBuilder<>) if (!controllerType.IsDefined(typeof(ApiVersionAttribute), true))
.MakeGenericType(controllerType) {
.GetMethod("IsApiVersionNeutral") typeof(ControllerApiVersionConventionBuilder<>)
.Invoke(controllerBuilder, null); .MakeGenericType(controllerType)
.GetMethod("IsApiVersionNeutral")
.Invoke(controllerBuilder, null);
}
} }
} }
} }

16
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")] [Route("api/v{api-version:apiVersion}/identity/fixture")]
public class FixtureController : AbpController, IRemoteService public class FixtureController : AbpController, IRemoteService
{ {
[HttpGet] [HttpGet, MapToApiVersion("2.0")]
public int Get() public int Get()
{ {
return 42; return 41;
} }
//[HttpGet, MapToApiVersion("3.0")] [HttpGet, MapToApiVersion("3.0")]
//public int Get3() public int Get3()
//{ {
// return 42; return 42;
//} }
[HttpPost] [HttpPost]
public int Post() public int Post()
{ {
return 42; return 43;
} }
} }
} }
Loading…
Cancel
Save