I'm writing a spec for an API where the fields included in the response vary. I would like to be able to provide more than one example to show this. My use cases are:
- One of the API calls has an
include
parameter which allows the user to specify some additional fields to be included in the response - For some API calls, the fields included in the response depend on permissions associated with the user's API key
What I'd like to be able to do is something like this:
+ Response 200 (application/json)
{
"id": 1,
"name": "Joe Bloggs",
"email": "[email protected]"
}
+ Response 200 (application/json)
If `include=telephone` was specified:
{
"id": 1,
"name": "Joe Bloggs",
"email": "[email protected]",
"telephone": "0123456789"
}
+ Response 200 (application/json)
If the API key has access to address data:
{
"id": 1,
"name": "Joe Bloggs",
"email": "[email protected]",
"address": [{
"address1": "101 My street",
"address2": "My area"
}]
}
As far as I can tell, although you can provide multiple responses, you can only do so if the response code or content type differ. Is there any way to do this?