Forum Discussion

tloubrieu's avatar
tloubrieu
New Member
4 years ago

multiple response type for a single API entry-point, different reponse mime-type

Hello,

 

When using the Java code-gen, we are running into an issue where we cannot return multiple different formats in our responses.

In our OpenAPI YAML we want to do something like this:

 

 

content:
  application/json:
    schema:
      $ref: '#/components/schemas/product'
  application/pds4+json:
    schema:
      $ref: '#/components/schemas/differentProduct’



But with the Java code-gen, this strongly types the object based upon the first response in the YAML, so we can never actually return the format we want from application/pds4+json. Until now, we have had a workaround of:

content:
  '*/*':
    schema:
      type: object
  application/json:
    schema:
      $ref: '#/components/schemas/product'
  application/pds4+json:
    schema: 
      $ref: '#/components/schemas/differentProduct'


So we can have an Object type returned instead.

Do you have any recommendations about how we can solve this issue? Is this just an issue in Java that cannot be avoided and we should look to use another technology?

Thanks

No RepliesBe the first to reply