Skip to content

ApiExplorer not handling multiple routes on same action method correctly #26234

Closed
@domaindrivendev

Description

@domaindrivendev

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

Metadata

Metadata

Assignees

Labels

affected-fewThis issue impacts only small number of customersbugThis issue describes a behavior which is not expected - a bug.old-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labelsseverity-minorThis label is used by an internal tool

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions