Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Equivalent path already exists #788

Closed
pkupilas opened this issue Sep 13, 2016 · 3 comments
Closed

[Question] Equivalent path already exists #788

pkupilas opened this issue Sep 13, 2016 · 3 comments

Comments

@pkupilas
Copy link

Is it any way to difference two similar paths with different parameter?
Swagger returs error:
Equivalent path already exists: /api/integration/message/v1/suppvouch/{id}
Example:

  '/api/integration/message/v1/suppvouch/{message}':
    post:
      parameters:
        - type: string
          name: message
          in: path
          required: true
          x-nullable: false
        - type: string
          name: correalationKey
          in: query
          required: true
          x-nullable: true
      responses:
        '200':
          description: ''
          schema:
            type: integer
          x-nullable: false
  '/api/integration/message/v1/suppvouch/{id}':
    put:
      parameters:
        - type: integer
          name: id
          in: path
          required: true
          x-nullable: false
        - name: newStatus
          in: body
          schema:
            type: string
          x-nullable: true
      responses:
        '204':
          description: ''
@ePaul
Copy link
Contributor

ePaul commented Sep 13, 2016

In OpenAPI 2.0, no (though there is a workaround: #146 (comment)). Related issues: #146, #164, #270.

In your example, I guess the server could distinguish both variants from the presence of the query parameter or the request body, but I don't know how this would work in a general case.

@darrelmiller
Copy link
Member

darrelmiller commented Sep 13, 2016

@pkupilas I'm assuming you are trying to describe an existing system that can't be changed rather that one that you are building. But just in case I'm wrong, allow me to suggest that using the type system of the implementation language to determine which operation to match is opening the door to a world of edge cases.

Different languages to completely different things when it comes to coercing string literals into native types. You don't want to expose behaviour of your chosen language through your HTTP interface.

Consider the following URLs and which operation they would map to:

/api/integration/message/v1/suppvouch/1.0
/api/integration/message/v1/suppvouch/1%20001
/api/integration/message/v1/suppvouch/232,200

Using an extra constant path segment to identify the desired operation is more reliable, more understandable and will perform better. Forgive me if I'm "preaching to the choir".

In fact, the following syntax is completely valid, although not common, for URLs also:

/api/integration/message/v1/suppvouch/message={message}
/api/integration/message/v1/suppvouch/id={id}

@fehguy
Copy link
Contributor

fehguy commented Sep 29, 2016

Yes, while this is technically possible to route on a server, it's impossible, from a URI, to determine if a path segment /1/ is a string ("1") or number (1).

For now, this is not supported, and it is expected that these paths are equivalent.

One could provide formatting requirements to a path parameter, for example, and say that {message} can either be an integer or an email address, which are easy to discern. But that's a very contrived example, and pretty much all tooling will get it wrong. So for now, no that is not supported. Path segments of different types will be treated to be equivalent and fail the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants