Closed
Description
I have a controller with an action that specifies a route constraint. Here is a snippet.
namespace Foo
{
[ApiVersion("1.0")]
[Produces("application/json")]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
public sealed class ValuesController : ControllerBase
{
[HttpPut("{id:guid}")]
public async Task<IActionResult> PutValueAsync(
[FromRoute] Guid id,
[FromBody] Value value)
{
}
}
If I make a request with a valid GUID in the path (i.e. PUT /api/v1/12345678-90ab-cdef-1234-567890abcdef
), everything works as expected. But if I use an invalid GUID in the path (e.g. PUT /api/v1/1234
), I get a 400 with the following body:
{
"error": {
"code": "UnsupportedApiVersion",
"message": "The HTTP resource that matches the request URI 'https://localhost:5001/api/v1/consumers/be4d7d66-f01d-4766-a71d-66c0d82d947/consumption' does not support the API version '1'.",
"innerError": null
}
}
I'm expecting a 404 because no route is supposed to match, according to the documentation.
I'm using ASP.NET Core 2.2 and API Versioning version 3.1.