Forum Discussion

silverbullet2's avatar
silverbullet2
New Contributor
4 years ago

OpenAPI Discrimintors

I have been trying to figure out how to handle a situation where a query string parameter changes the response object.  Here's my example:
The default response is this:
endpoint: http://myapi.com/pets

response: 

 

{
pet:{
name: "barry",
color: "white",
age: 17
}
}

 

 

It can also have a query string parameter where it adjusts the response as follows:

endpoint: http://myapi.com/pets?attributes=name,color

response: 

 

 

{
pet:{
name: "barry"
}
}

 

 

 

It also supports comma separated lists for the parameter as well like this:

endpoint: http://myapi.com/pets

response: 

 

 

{
pet:{
name: "barry",
color: "white"
}
}

 

 

 

Is there a way to describe this scenario using discriminators?  I know that I can list the responses as optional, but that wasn't ideal.

 

Thanks!