sway: Spec with duplicated paths but different methods should be valid

Following is valid Swagger:

{
  "info": {
    "title": "test",
    "version": "1.0.0",
  },
  "paths": {
    "/{arg1}": {
      "get": {
        "parameters": [
          {
            "name": "arg1",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": { "description": "OK" }
        }
      }
    },
    "/{arg2}": {
      "head": {
        "parameters": [
          {
            "name": "arg2",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": { "description": "OK" }
        }
      }
    }
  },
  "swagger": "2.0"
}

But currently it throws an error:

[
  {
    "code": "EQUIVALENT_PATH",
    "message": "Equivalent path already exists: /{arg2}",
    "path": [
      "paths",
      "/{arg2}"
    ]
  }
]

P.S. I have PR, but I submit issues just to mark it properly in tests.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 22 (14 by maintainers)

Most upvoted comments

It’s quite simple:

# ...
paths:
  /user/{id}:
    delete:
      # Operation details for DELETE
    get:
      # Operation details for GET
    put:
      # Operation details for PUT
# ...

The Paths Object and Path Item Object documentation should explain.

Also, next time…please start a new issue when asking for help, especially when the issue you commented on is unrelated to the question being asked. (Your question is unrelated because you have 3 operations for the same path and the issue is about how OpenAPI treats paths that are technically different but functionally the same.)

@whitlockjc Yes, they are equivalent but set of methods is different, so router can function properly. So you should think of pairs ["/pet/{petId}", "GET"] and ["/pet/{id}", "HEAD"], and there are no conflicts. @webron I couldn’t find anything in spec that forbid this behaviour. It also used in APIs and even in swagger specs.

Spec with duplicated paths but different methods should be valid @whitlockjc @mohsen1 Yes, paths exactly the same but one have get method and another have head method. So no conflict during call.

As @mohsen1 said, they are not different paths. There is no way to tell whether /foo and /bar should go to /{arg1} or /{arg2}. At best you could do some type-based decision but in reality, the path is the same regardless. I’ll keep it open for discussion but I don’t think we’ll be supporting this.