Papi
27 November 2026

Contract-First, for Real

What it is

Contract-driven development means the shape of an API is agreed before either side builds it. The endpoints, what they accept, what they answer. Both sides then build against that agreement, and when the code and the contract disagree, the code is wrong.

Why it matters

  • Both sides start on day one. The frontend does not wait for the backend to exist; it waits for the contract, which takes an afternoon.
  • The argument happens while it is cheap. Renaming a field in a proposal costs a comment. Renaming it after three clients ship costs a migration.
  • Reviewers review the design. A contract is fifty lines. The controller that implements it is two thousand, and nobody reviews the shape of an API by reading a controller.
  • Consumers read one thing. Another team, a partner, an agent writing a client: they all read the contract, not your code.

Common mistakes

The contract is generated from the code. Then it is documentation, written last, describing whatever got built. Annotations on controllers produce a perfectly accurate spec that nobody ever agreed to.

The contract changes by commit. Somebody edits the YAML in the same pull request as the implementation. The people who consume the API were never asked.

The contract cannot run. If the frontend cannot call it, the frontend waits for the backend anyway, and the contract is a diagram.

The review is a text diff. Five hundred lines of reindented YAML, where the one change that matters hides between two that do not.

Every change looks the same. A new optional field and a removed endpoint arrive in the same kind of diff, with the same weight.

The contract is too heavy to write first. If declaring an object takes a dozen lines of nested YAML, people write the code first and the spec never.

What Papi does about each

Each of these has an answer in Papi, walked through in What Swagger Misses. The one that changes the most is the contract that cannot run, because an open candidate is already a server:

curl "https://papidev.com/projects/shop/candidates/12/orders/1?mock_token=…"

It answers with an example built from the declared response, before anyone has written the endpoint. The frontend builds against that, and the contract stops being a diagram.

Who it is for

Teams where the person who writes an API is not the person who calls it: a frontend and a backend, two services, a public API, an agent. If you are both sides of your own API, you already have a contract. It is in your head.

← All posts