An API modification changes an interface that consumers may already depend on. New needs and consumer feedback make changes inevitable, but a change to a response, request, or behavior can break applications—or cause less visible errors. Design the modification around user needs and consumer impact, not just the shape of the new interface. section 15.0 section 15.1
Adding multiple currencies
Suppose a product has a numeric `price`. Replacing it with an object containing a value and currency lets the API represent multiple currencies, but existing consumers expect a number when reading products and send a number when adding them. One alternative is to keep `price` and add `priceCurrency` with a default value. That preserves existing consumer behavior, though it gives up the preferred grouped design. If the object is worth the disruption, running old and new API versions in parallel lets partners migrate at their own pace; synchronizing a single internal consumer may be simpler. section 15.1.1
For each proposed modification:
- Identify the new or changed capability, then list every interface change so implementers and consumers can assess what must change. section 15.1.2 section 15.1.3
- Check backward compatibility and security. Weigh the value of a breaking change against its effects on actual consumers; revise the design when the cost is too high. section 15.1.2
- If a break remains, plan migration within the versioning policy: decide how versions are identified, whether they can run concurrently, and how long older versions remain supported. Update the API description, version number, and change log. section 15.1.2 section 15.1.3
Practice on `GET /machine-reports/{reportId}`: compare its original and modified response schemas. List changes to required fields, names, types, accepted identifier patterns, and units—not just newly added properties. Then decide which changes existing consumers can tolerate. Designing for extensibility before an API is consumed can reduce these difficult trade-offs later. section 15.12 section 1.3.2
Listing 15.4 Response body data before modification
required:
- id
- machineIdentifier
- conditionComment
- conditionStatus
properties:
id:
type: string
pattern: "[0-9]{10}"
date:
type: integer
conditionComment:
type: string
conditionStatus:
type: string
enum:
- green
- orange
- red
machineIdentifier:
type: integer
status:
type: string
enum:
- running
- stopped
- maintenance
temperature:
type: number
description: Celsius.
Use the original machine-report response schema as the baseline for the compatibility check. section 15.12
Listing 15.5 Response body data after modifications
required:
- id
- date
- machineId
- condition
properties:
id:
type: string
pattern: "[a-z]{3}-[0-9]{10}"
date:
type: string
format: date-time
condition
required:
- conditionComment
- conditionStatus
properties:
conditionComment:
type: string
conditionStatus:
type: string
enum:
- green
- orange
- red
machineId:
type: integer
status:
type: string
enum:
- running
- stopped
- maintenance
temperature:
type: number
description: Farhenheit.
pressure:
type: number
description: Kilopascals.
Compare the modified schema with the baseline; inspect the changed identifier pattern, date type, field structure, and temperature unit. section 15.12
