I need to define swagger/OpenAPI v 3.0 file for a search API. My request can specify either geospatial coordinates (longitude and latitude) or (postal code and country code) or (city and state and country code). Beside these I do have couple more mandatory attributes, like distance and distanceUnits.
I know how to do it in JSON schema
"dependencies": {
"postalCode": ["countryCode"],
"city": ["state", "countryCode"],
"longitude": ["latitude"],
"latitude": ["longitude"]
},
"anyOf": [
{
"required": ["longitude", "latitude"]
},
{
"required": ["postalCode", "countryCode"]
},
{
"required": ["city", "state", "countryCode"]
}
]
}
but I have troubles defining it in swagger. OpenAPI 3.0 allows oneOf and anyOf constructs, but if I am trying to use it in required section, swagger editor gives me an error.
Any help will be greatly appreciated.