Skip to content

PathMustBeUnique doesn't consider the HTTP Method #1449

Closed as not planned
Closed as not planned

Description

@j2ghz

Describe the bug
#474 introduced a PathMustBeUnique validator, but it only check that a path is unique.

To Reproduce
Steps to reproduce the current behavior:
Have 2 endpoints with the same path but different method, e.g. GET /user and DELETE /user

Expected behavior
It should check that a combination of HTTP method and path is unique.

Activity

  1. darrelmiller commented on Nov 28, 2023

    @darrelmiller
    Member

    Are you creating the GET and DELETE operations under two different path items? If you create both GET and DELETE under the same path Item there should not be any error. Can you show an example of an OpenAPI description that gives you an error.

  2. marcusber commented on Nov 29, 2023

    @marcusber

    Darrel (@darrelmiller) :

    Created a small test to illustrate the problem.

    The controller looked like this:

    using Microsoft.AspNetCore.Mvc;
    
    namespace OpenApi.IntegrationTest;
    [Route("api/v2/someroute/areatype")]
    public class TestController : ControllerBase
    {
        [HttpGet("{index}/{arg}")]
        public ActionResult Get(long index, string arg)
        {
            return Ok("Get");
        }
    
        [HttpPut("{index}/{language}")]
        public ActionResult Put(int index, string language, string text) {
            return Ok("Update");
        }
    }
  3. baywet commented on Feb 27, 2025

    @baywet
    Member

    Thank you for the additional information.

    This is actually exactly prevented by the specification because it leads to ambiguous resolution.

    This would need to be addressed at the specification level where the path parameters should be disambiguated considering the type as well.

    Closing as until the specification changes, there nothing that can be done here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions