2

I'm working with Swagger Editor to create an API, and in implementing a search endpoint, I am trying to do something like this:

/pets:
    get:
      summary: Retrieve a list of pets
      description: Retrieve a list of pets based on search parameters
      parameters:
        - name: countryCode
          in: query
          description: The ISO 2-digit country code.
          required: false
          type: string
        - name: subdivisionCode
          in: query
          description: The ISO subdivision code.
          required: false
          type: string

I ONLY want subdivisionCode to be required if countryCode is included, otherwise they are both optional.

Is there a way to accomplish this in Swagger?

Thanks!

Chris
  • 322
  • 1
  • 9
  • 1
    It's not possible. You can follow this proposal for updates: https://github.com/OAI/OpenAPI-Specification/issues/256 – Helen Apr 12 '17 at 08:27
  • @Helen thanks for the response! It would appear this is a duplicate. I hadn't noticed because the question is worded completely differently! Thanks for pointing it out. – Chris Apr 12 '17 at 17:10
  • It's now possible (sort of) in OpenAPI 3.0 - see [this answer](https://stackoverflow.com/a/49199240/113116). – Helen Mar 09 '18 at 17:44

0 Answers0