How to Detect Drift Between Your OpenAPI Spec and Your Live API
Your OpenAPI spec says the order endpoint returns tracking_number. Since last Tuesday's deploy the endpoint returns trackingNumber, and it still answers with a 200 in the same time it always did. Every uptime check stays green, so the first report comes from a consumer whose parser broke.
That gap between what the spec promises and what the live API returns is called drift. A review checklist doesn't close it, because the checklist depends on the person under the most time pressure remembering the step with the least visible payoff. You detect drift by letting a machine compare the spec with the API.
With Routebase, that comparison runs in three places, and all three read the same published spec. A spec change is checked before it merges, a build is checked before it ships, and production is checked on a schedule. This post walks through the three checks with the order endpoint as the example.
What drift looks like on the wire
The spec declares the response of GET /orders/{id} with three required fields.
Order: type: object required: [id, tracking_number, total] properties: id: type: string tracking_number: type: string total: type: number The live API answers with a 200 and this body.
{ "id": "ord_8141", "trackingNumber": "1Z999AA10123456784", "total": "49.90", "warehouse": "BER-2" } A status check sees nothing wrong with that response, while a schema check finds three deviations that deserve different reactions.
| Deviation | Severity | Why |
|---|---|---|
The required field tracking_number is missing | Breaking | Every consumer that reads it fails |
total arrived as a string where the spec documents a number | Breaking | A consumer that calculates with the value gets an error or a wrong result |
The undocumented field warehouse appeared | Informational | Most consumers ignore it, and it becomes contract once somebody depends on it |
How often such gaps open is measurable in public APIs. In September 2026 we fetched 1,927 public OpenAPI specs from their original URLs and compared each with its copy from 2023. Of the contracts that could still be compared, 48.9 percent had changed in a way a client can observe. Two thirds of those changes included at least one breaking change, and 88.8 percent of the breaking changes came without a new major version. The method and the open data are in the corpus study.
Three checks that compare the spec with the API
Each check answers a different question, so a team that runs only one of them still has a window in which drift goes unseen.
| Where it runs | What it compares | What it catches | What it can't see |
|---|---|---|---|
| On every spec change | The new spec version with the previous one | A breaking change somebody wrote into the spec | An API that changed while the spec stood still |
| In CI, against a deployed build | Real responses with the documented schema | An implementation that deviates before the release | A change that reaches production outside the pipeline |
| In production, on a schedule | Live responses with the version the environment serves | Drift that is live right now, with the time it started | Endpoints that no check calls |
1. Check every spec change before it merges
A spec change can break a client on its own, for example when it removes a field, narrows a type or adds a required parameter. When you compare two versions in Routebase, every difference is classified as breaking, safe or a deprecation, down to the field, the parameter and the response. On a spec branch, the merge request reports the breaking changes it would introduce before anything merges.
If your spec is generated from code, the same check runs in your pipeline. The pull request job pushes the generated file as a dry run, and a breaking change against the draft ends the job with exit code 6 and a list of what broke.
- uses: routebase-dev/routebase-action@v3 with: command: spec-push api-key: ${{ secrets.ROUTEBASE_API_KEY }} project: ${{ vars.ROUTEBASE_PROJECT_ID }} spec: Orders API file: openapi.json dry-run: true This check reads two documents, so it protects you from a spec that changes carelessly. A service whose code changed while nobody edited the spec is the job of the second check.
2. Run contract tests against the deployed build
A contract test calls a documented endpoint on a running build and validates the response body against the schema the spec declares. In Routebase you link a test case to an endpoint, and the case gets a Schema Validation assertion that reads the endpoint's documented schema. You don't have to start from an empty suite, because the Import button creates test cases from the endpoints of a spec with assertions derived from their contract.
The GitHub Action runs the suite against your staging environment after the deploy step, and the CLI does the same in any other pipeline.
- uses: routebase-dev/routebase-action@v3 with: command: run api-key: ${{ secrets.ROUTEBASE_API_KEY }} project: ${{ vars.ROUTEBASE_PROJECT_ID }} suite: ${{ vars.ROUTEBASE_SUITE_ID }} environment: staging format: junit output: reports/routebase.xml When the build returns trackingNumber where the spec requires tracking_number, the run fails with exit code 1 although the status is still 200. As a result, the pipeline stops before the change reaches a consumer. The guide to contract testing covers the assertion in detail.
3. Validate live responses in production
The first two checks cover the time before a release. Production still changes afterwards, whether through a hotfix, a configuration change or a dependency that started returning something new. Routebase monitors close that window, because every monitor check that gets a response validates it against the contract.
Two settings decide whether this check produces signal or noise. The first setting is the contract, which is the version the environment is pinned to and never the newest draft. Your deploy job sets that pin with one command.
routebase promote "Orders API" 2.1.0 --env production The second setting is the validation mode. In Warn mode a deviation is recorded and alerted while the check stays green, so a correctness problem stays out of your uptime figure. In Strict mode breaking drift fails the check, which is right for an endpoint whose consumers would call a shape change an outage.
You don't set this up endpoint by endpoint. One dialog named Watch this API for drift creates a monitor with schema validation for every endpoint of a spec in one environment.
What a drift event tells you
A failed assertion in a log is not enough for production, because drift may stay open for days while the team decides whether the spec or the service is wrong. Routebase therefore turns a deviation that keeps appearing into a drift event, and the event carries what that decision needs:
- The field path, the kind of change, and the expected and the received value.
- A first-seen date that never moves, so reopening an event doesn't reset how long the deviation has been live.
- An observation count, because a deviation seen on sixty checks is a deploy and a deviation seen once is a blip.
- The spec version it was checked against, so history stays readable after the environment moves to a newer version.
The event resolves itself when a later check matches the contract again, and drift alerts reach your team in Slack or Microsoft Teams.
Where the open-source projects for this job stand
Answers to this question often name four open-source projects. We checked their GitHub repositories on December 2, 2026.
| Project | What it compares | Repository status |
|---|---|---|
| oasdiff | Two OpenAPI documents | Active |
| Schemathesis | Responses of a running API with its schema | Active |
| Dredd | An API description with a backend implementation | Archived on November 8, 2024 |
| Optic | Spec versions, and test traffic with the spec | Archived on January 12, 2026 |
The two active projects are command-line tools that run when your pipeline calls them, and each one covers a single comparison. The third check needs something that runs on a schedule, knows which version each environment is supposed to serve and keeps a record of what it saw.
One spec behind all three checks
Routebase is an API lifecycle platform where you design, mock, test, document and monitor an API from one living OpenAPI spec. As a result, the three checks read the same contract instead of separate copies of it, so your tests and your monitors validate against the version you published.
The production check is explained step by step in contract drift monitoring, and the page for API monitoring shows how drift events, alert policies and incidents fit together. You can start on the Free plan, and drift monitoring comes with the 14-day Pro trial, which needs no credit card.