-
Notifications
You must be signed in to change notification settings - Fork 698
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the reporting of API versions when conventions are used and add…
…ed additional test coverage. Fixes #47.
- Loading branch information
Chris Martinez
committed
Nov 7, 2016
1 parent
664d76a
commit db3261f
Showing
8 changed files
with
144 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...soft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/Controllers/HelloWorld2Controller.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Microsoft.Web.Http.Conventions.Controllers | ||
{ | ||
using System.Web.Http; | ||
|
||
[RoutePrefix( "api/v{version:apiVersion}/helloworld" )] | ||
public class HelloWorld2Controller : ApiController | ||
{ | ||
[Route] | ||
public IHttpActionResult Get() => Ok( new { controller = GetType().Name, version = Request.GetRequestedApiVersion().ToString() } ); | ||
|
||
[Route( "{id:int}" )] | ||
public IHttpActionResult Get( int id ) => Ok( new { controller = GetType().Name, id = id, version = Request.GetRequestedApiVersion().ToString() } ); | ||
|
||
[Route] | ||
public IHttpActionResult GetV3() => Ok( new { controller = GetType().Name, version = Request.GetRequestedApiVersion().ToString() } ); | ||
|
||
[Route( "{id:int}" )] | ||
public IHttpActionResult GetV3( int id ) => Ok( new { controller = GetType().Name, id = id, version = Request.GetRequestedApiVersion().ToString() } ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...icrosoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/Controllers/HelloWorld2Controller.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Microsoft.AspNetCore.Mvc.Conventions.Controllers | ||
{ | ||
using AspNetCore.Routing; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System; | ||
|
||
[Route( "api/v{version:apiVersion}/helloworld" )] | ||
public class HelloWorld2Controller : Controller | ||
{ | ||
[HttpGet] | ||
public IActionResult Get() => Ok( new { Controller = nameof( HelloWorld2Controller ), Version = HttpContext.GetRequestedApiVersion().ToString() } ); | ||
|
||
[HttpGet( "{id:int}" )] | ||
public IActionResult Get( int id ) => Ok( new { Controller = nameof( HelloWorld2Controller ), Id = id, Version = HttpContext.GetRequestedApiVersion().ToString() } ); | ||
|
||
[HttpGet] | ||
public IActionResult GetV3() => Ok( new { Controller = nameof( HelloWorld2Controller ), Version = HttpContext.GetRequestedApiVersion().ToString() } ); | ||
|
||
[HttpGet( "{id:int}" )] | ||
public IActionResult GetV3( int id ) => Ok( new { Controller = nameof( HelloWorld2Controller ), Id = id, Version = HttpContext.GetRequestedApiVersion().ToString() } ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters