Skip to content

Lesson 9 of 9 · 23m

Documentation Contracts and Honest Deprecation

OpenAPI as a tested contract, examples that stay true, SDK compatibility, migration guides, and deprecation as an engineering process.

Documentation is not marketing copy for endpoints; it is the part of the API contract humans read. If docs say one thing and production does another, production loses even when production is right. Treat documentation as executable, versioned, and operationally owned, or it will decay into a museum of how the API worked two years ago.

OpenAPI is the contract artifact, not just a docs generator

openapi: 3.1.0
info:
  title: Billing API
  version: "2026-11"
paths:
  /invoices/{invoice}:
    get:
      operationId: getInvoice
      parameters:
        - name: invoice
          in: path
          required: true
          schema:
            type: string
            pattern: "^inv_[A-Za-z0-9]+$"
      responses:
        "200":
          description: Invoice found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Invoice"
        "404":
          description: Invoice not found
          content:
            application/problem+json:
              schema:
                $ref: "#/components/schemas/Problem"

The value comes from using the spec everywhere: validating responses in CI, generating client SDKs, building mock servers, detecting breaking diffs, and rendering reference docs. A hand-maintained spec that lags implementation is worse than none because it carries false authority.

Examples are tests waiting to happen

Developers copy examples verbatim. That means examples must use realistic identifiers, valid enum values, correct nesting, and current required fields. Generate them from fixtures or validate them against schemas in CI. If the example uses "status": "pending" but the enum is "requires_confirmation", every new integrator starts with a failed request.

Include unhappy examples too: validation errors, rate limiting, idempotency replay, version conflicts. Most integration time is spent in edge behavior, not the first happy path.

Changelogs need migration intent

A changelog entry saying invoice.total_cents renamed to amount_due_cents is incomplete. A migration note says why, when behavior changes, how long both are available, and gives before/after code:

{"amount_due_cents": 12900, "total_cents": 12900}

Ship dual fields during the transition if you can do so honestly. Announce removal with dates, sunset headers, account-level telemetry, and direct migration instructions.

Deprecation is an engineering system

A credible deprecation pipeline has stages:

  1. Mark documentation and schema deprecated.
  2. Emit runtime Deprecation and Sunset headers.
  3. Measure usage by client, key, or account.
  4. Contact high-impact integrators with concrete migration steps.
  5. Enforce brownouts or opt-outs only after notice.
  6. Remove, then keep documentation for the historical behavior.

Skipping measurement turns deprecation into roulette. Skipping communication turns your compliance process into a surprise outage.

Contracts include operational behavior

Document rate limits, pagination ceilings, webhook retry schedules, idempotency retention, consistency expectations, and supported TLS/client versions. These are not implementation trivia; integrators design systems around them. If you cannot commit to a behavior, say it is best-effort rather than leaving readers to assume a guarantee.

Field notes

  • Put docs source in the same repository or pipeline as the API implementation so review happens together.
  • Breaking-change detection belongs in CI, but humans still classify semantic changes the tools cannot understand.
  • Never document aspirational behavior before launch; integrators will build against the promise.
  • Keep a migration guide for every breaking version even after removal. Old integrators return years later.

Was this lesson helpful?

Sign in to rate