OpenAPI.NET icon indicating copy to clipboard operation
OpenAPI.NET copied to clipboard

PathMustBeUnique doesn't consider the HTTP Method

Open j2ghz opened this issue 2 years ago • 2 comments

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.

j2ghz avatar Nov 02 '23 10:11 j2ghz

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.

darrelmiller avatar Nov 28 '23 14:11 darrelmiller

@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");
    }
}

marcusber avatar Nov 29 '23 10:11 marcusber