I am using the ASP Versioning library to version an MVC controller Rest API in a microservice.
using Asp.Versioning;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
[ApiController]
[ApiVersion("1")]
[ControllerName("example")]
[Route("v{version:apiVersion}/[controller]")]
within this controller I have a few actions, e.g. one to get the version:
[HttpGet("version")]
[Produces("text/plain")]
[ProducesResponseType(StatusCodes.Status200OK)]
public IActionResult GetVersion() => ...
If I perform a curl
GET operation with any version number, I get the matched route for version. In some ways this is not surprising, because I am using version neutral matching for the action. However, given that the controller route has an [ApiVersion] of 1 only, I expected any other non-declared version number to result in a 404 not found.
curl -X GET http://localhost:8127/v1/system/version
0.0.0.0%
curl -X GET http://localhost:8127/v1337/system/version
0.0.0.0%
Have I mis-configured this? Is it possible to have non-declared versions rejected rather than matched?