Forum Discussion

jbao81's avatar
jbao81
New Member
7 months ago

API response type backwards compatible?

Right now, I have a POST endpoint schema returning an empty 200 response.

 

      responses:
        '200':
          description: The resource was found.

 

I want to make the change in the schema to return a response object now.

 

      responses:
        '200':
          description: The resource was found.
          content:
            application/json:
              schema: {}

 

I want to know if what I'm trying to do in the schema is possible in a backwards compatible way as logic currently sends '200' and I don't want anything to break by rolling out schema changes first. I want to specify the schema in a way that allows both cases to be valid: the server can either send an empty 200 response (not an empty object, but None) OR it can send an actual response object as well.

Is this possible? Would appreciate any insight 🙂

1 Reply

  • chichepo's avatar
    chichepo
    Champion Level 3

    Hi jbao81 

    Your changes seems to be correct in order to address your new requirement.
    Be aware that the response is not validated against any rules and can include unwanted data.