How to define mutually exclusive query parameters in Swagger (OpenAPI)?
openapi, swagger
Solution
Unfortunately this isn't possible currently. "required" is just a boolean and there's no way to represent interdependencies between parameters.
Best you can do is make clear the requirements in the parameter descriptions and also put in a custom 400 Bad Request description along the same lines.
There's a bit of discussion at https://github.com/OAI/OpenAPI-Specification/issues/256 about possible ways of implementing this in the next version of the OpenAPI Specification.
Problem
I have a series of parameters in Swagger like this ``` "parameters": [ { "name": "username", "description": "Fetch username by username/email", "required": false, "type": "string", "paramType": "query" }, { "name": "site", "description": "Fetch username by site", "required": false, "type": "string", "paramType": "query" }, { "name": "survey", "description": "Fetch username by survey", "required": false, "type": "string", "paramType": "query" } ], ``` One parameter MUST be filled out but it doesn't matter which one, the others can be left blank. Is there a way to represent this in Swagger?