Closed
Description
Describe the bug
Given the following action method bound to multiple routes:
[HttpGet]
[Route("foo")]
[Route("bar/{id}")]
public IActionResult Get(int id = 0)
As expected, the ApiExplorer surfaces two ApiDescription
instances, one for each route. However, for the first route "foo", the ApiDescription
includes the id
path parameter, despite the fact that it's not part of the route template. For example, here's the ApiExplorer data (serialized as json):
[
{
relativePath: "Test/foo",
httpMethod: "GET",
parameters: [
{
name: "id",
source: {
displayName: "Path",
id: "Path",
isGreedy: false,
isFromRequest: true,
},
}
],
},
{
relativePath: "Test/bar/{id}",
httpMethod: "GET",
parameters: [
{
name: "id",
source: {
displayName: "Path",
id: "Path",
isGreedy: false,
isFromRequest: true,
},
}
],
},
]
To Reproduce
> git clone git@github.com:domaindrivendev/ApiExplorerIssue.git
> cd ApiExplorerIssue
> dotnet run
Then navigate to "http://localhost:5000/apidescriptions" to see the ApiExplorer data
Further technical details
- ASP.NET Core version: 3.1