When two clients expect different versions of a response

Test an optional API field with three JSON examples. Check what older clients accept and how the new screen handles omission and null.

Two precisely shaped metal blocks fitting a single purple connector

One app build expects a contact name. A newer screen understands a display label and will show a fallback when the label is missing. The server team has to serve both builds for a while. A field rename is easy to write in a schema. Its compatibility depends on what the running clients do with the result.

Put the two examples beside the definition

Use a small fixture with the old response and one with the proposed response. The OpenAPI specification describes ways to document operation responses, schemas and examples. A fixture can make the timing of your contract change easier to review. Run it against each consumer you intend to support.

Here is the response the original client reads. The second response keeps name and adds an optional displayLabel.

Original response

{
  "name": "Alex"
}

Response with a label

{
  "name": "Alex",
  "displayLabel": "Alex from support"
}

A client that reads name and ignores extra fields still shows Alex. An older client that rejects unknown keys can fail before it renders anything. Run both builds against the second response. Verify the value on screen as well as whether parsing succeeded.

Test a value that is legitimately unavailable

Response with a deliberately null label

{
  "name": "Alex",
  "displayLabel": null
}

This newer screen displays the label when it receives a string. It falls back to Alex when the field is absent and shows “Label withheld” for a deliberate null. The old response above doubles as the test with the label absent. These meanings are part of this example’s contract.

OpenAPI 3.2 response schema

{
  "type": "object",
  "required": ["name"],
  "properties": {
    "name": { "type": "string" },
    "displayLabel": {
      "type": ["string", "null"]
    }
  }
}

In this schema, leaving the label out of required allows omission. Including null in its type allows an explicit null. Keep name until production evidence supports retiring the original client contract.

Record which applications are expected to send or receive each shape and when support for the older one can be reviewed. For the first production release, measure the result using logs or compatibility tests the service actually has.

The most useful contract change tells a team what to expect during the overlap. When the least recently updated client can still make sense of the response, the release plan has something concrete to point to.