Skip to content

Lesson 7 of 9 · 27m

Versioning Through the Spec: Compatibility Is the Default

Classify additive and breaking changes honestly, choose a versioning strategy, and use compatibility checks before consumers pay for accidental drift.

Versioning discussions usually begin too late, after someone says “it's just a small rename.” A rename is a breaking change. So is removing a field, narrowing accepted values, changing error shape, tightening validation, altering pagination semantics, or changing the meaning of an existing enum. Compatibility is not whether the URL stayed the same; it is whether existing consumers can continue operating without coordinated change.

Build a compatibility taxonomy

Use a shared vocabulary:

Usually additive: new optional request fields, response fields, endpoints.
Usually breaking: removal or rename; type/format change; newly required input;
narrowed validation or enums; changed status, errors, pagination, sorting, or idempotency.

There are exceptions. A new response enum value can break strict consumers even though the provider only “added” something. Document forward-compatibility expectations explicitly.

OpenAPI diff tools catch drift, not intent

Tools like oasdiff can classify changes:

oasdiff breaking openapi-v1.yaml openapi-next.yaml && oasdiff changelog openapi-v1.yaml openapi-next.yaml

Run this in CI. A machine-readable diff gives reviewers the right conversation: is this breakage intentional, versioned, and communicated? The tool cannot decide whether the product may break consumers.

Pick a versioning strategy you can govern

Path versioning is explicit and operationally simple:

/v1/orders
/v2/orders

Header or media-type versioning can be elegant but is easier to ignore in logs, browser debugging, documentation, and support. No strategy is magic. The hard part is lifecycle: how many versions run, how long they are supported, who pays migration cost, and how you measure remaining usage.

Version behavior, not every microservice internally

Public API versions should be stable consumer-facing surfaces. Internal services can evolve faster behind adapters. If every internal schema change forces a public version bump, your architecture is exposing implementation seams.

Compatibility policy example

Write the promise down:

info:
  version: 1.4.0
  description: |
    Additive fields may appear; consumers must ignore unknown fields.
    Breaking changes require a new major path version.
    Deprecated operations remain for at least 180 days.

This is not legal boilerplate. It tells client authors how to write resilient integrations and tells engineers what freedom they still have.

Field notes

  • Tightening validation is breaking even when the old input was invalid by intention; some consumers may depend on the acceptance.
  • Changing a 404 to 403 can be breaking for clients that use it as a state machine.
  • Version numbers in info.version are contract revision metadata, not a substitute for URL or media-type version policy.
  • Keep compatibility reports as CI artifacts. Support and partner teams will ask exactly what changed.

Was this lesson helpful?

Sign in to rate