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

Either/or required but not both #286

Closed
marcus-maws opened this issue Feb 26, 2015 · 3 comments
Closed

Either/or required but not both #286

marcus-maws opened this issue Feb 26, 2015 · 3 comments

Comments

@marcus-maws
Copy link

Hi,

Is there any way in swagger definitions to specify that either one parameter or another is required, but not both?

e.g. firstname OR fullname is required, but not both

Thanks.

@mohsen1
Copy link
Contributor

mohsen1 commented Feb 26, 2015

As of Swagger 2.0 it's not possible. What you can do is defining this logic in your 400 response.

---
swagger: '2.0'
info:
  version: 1.0.0
  title: Pets Store
paths:
  /pets:
    get:
      parameters:
        - name: firstName
          in: query
          description: First Nam
          type: string
        - name: fullName
          in: query
          description: description
          type: string
      responses:
        400:
          description: |
            ##### Bad request
            You have to specifiy either `firstName` or `fullName` parameter.

@marcus-maws
Copy link
Author

Thanks. I was thinking of specifying it in the summary possibly in addition to your suggestion with the response.

@mohsen1
Copy link
Contributor

mohsen1 commented Feb 26, 2015

#256 is where we're discussion possibility of adding a feature for cases like this in Swagger.Next

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

2 participants