Add IsApiVersionNeutral only if not defined ApiVersionAttribute.

pull/122/head
Halil İbrahim Kalkan 8 years ago
parent beb9abb618
commit d655a65d5e

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

@ -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