Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When using Microsoft.AspNetCore.Mvc.Versioning 5.1.0, the error responses contained an error code
(e.g. ApiVersionUnspecified
). When upgrading to Asp.Versioning 8.1.0, the documentation states that it is possible to retain the previous "Error Object" format (which I would expect to include the code
property). However, even when using builder.Services.AddErrorObjects().AddProblemDetails()
, there is no code
property in the error response.
I'm seeing something like this:
{
"error": {
"message": "Unspecified API version",
"target": "Unspecified API version",
"innerError": {
"message": "An API version is required, but was not specified."
}
}
}
Expected Behavior
I expected the error response to match what is was in the older version (especially the code
property):
{
"error": {
"code": "ApiVersionUnspecified",
"message": "An API version is required, but was not specified.",
"innerError": null
}
}
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
8.0.204
Anything else?
I think this line of code is perhaps missing a not:
https://github.com/dotnet/aspnet-api-versioning/blob/main/src/AspNetCore/WebApi/src/Asp.Versioning.Http/Routing/EndpointProblem.cs#L28