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.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);
}
}
}
}

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")]
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;
}
}
}
Loading…
Cancel
Save