What Is API Documentation Drift? Examples and Fixes
TL;DR
- API documentation drift is the gap between what your API does and what your docs still say it does.
- It shows up in six places: endpoints, parameters, schemas, missing pages, code examples, and broken references.
- Code review misses it because the docs live in another folder and nothing fails when they go stale.
- The cheapest fix is a check on every pull request that shows both sides: what the docs say and what the code or OpenAPI spec says.
API documentation drift is when the code and the API contract change, but the documentation does not. The application is correct. The reference your customers follow is wrong. A typical change looks small in the pull request:
GET /api/users/:id
becomes:
GET /api/v2/users/:userId
The handler, the tests, and the OpenAPI file move together. The guide in docs/api/users.md still shows GET /api/users/{id}. A spell checker passes it. A link checker passes it. The page exists, the sentences are grammatical, and every link resolves. The contract is wrong.
Nobody gets an alert. The first signal is usually a support ticket from an integrator who copied the example and got a 404.
The six places API docs drift
Drift is not random. It shows up in the same six places, and each one has a recognizable shape.
Endpoints
The path, method, or version prefix changed and the page did not. POST /orders became POST /v2/orders, or a PUT became a PATCH. The old path may still respond for a while, which makes the stale page look fine.
Parameters
id became userId. A query parameter that used to be optional is now required. A filter was removed. The docs still list the old name, so a client sends it and gets a validation error, or worse, gets ignored silently.
Request and response schemas
The response now returns createdAt and the docs still describe created_at. A field changed from a string to an object. Developers who build types from your docs write code against a shape you no longer send.
Missing docs
A new public operation shipped with no page at all. This is drift in the other direction: the code moved ahead and the docs never caught up. If you want a number for this, count discovered operations that have a matching page. We cover that in documentation coverage for TypeScript APIs.
Code examples
A curl or TypeScript snippet posts a property the schema no longer accepts, or leaves out a field that is now required. Examples get copied more than any other part of the docs, so a broken one does the most damage.
Broken references
A guide links to an anchor for an operation that was removed or renamed. Link checking helps here, and it is worth running. But a link that 404s is a smaller problem than a page that confidently describes an API you no longer serve.
Spec drift and documentation drift are two different layers
Most API teams have two places where drift can happen, and most tooling only watches one of them.
| Layer | What is compared | What usually catches it | What it misses |
|---|---|---|---|
| Spec drift | OpenAPI file vs the routes and types in code | Generating the spec from code, contract tests, spec diffs in CI | Hand-written guides that quote the old contract |
| Documentation drift | Markdown/MDX guides, tutorials, and examples vs the spec and code | Very little, unless you check for it on purpose | Usually nothing is watching this layer |
If your API reference pages are generated from the OpenAPI Specification file, a correct spec gives you a correct reference. That is a good practice. It does not fix the quickstart, the migration guide, the authentication tutorial, or the README snippet a developer wrote by hand. Those files still say id after the spec says userId.
So "is our spec in sync with the code?" and "are our docs in sync with the spec?" are two separate questions. You need an answer to both.
Why code review misses it
Code review looks at the diff. The documentation lives in another directory, often owned by whoever last touched the guide. Reviewers check that the route works and the tests pass. They rarely open the Markdown and compare it to the OpenAPI operation by hand, on every pull request, for every parameter.
That works for a small API with one maintainer. It stops working once a team opens API changes every week. The green checks on the pull request make it worse: spelling passed, links passed, build passed, so the docs feel covered. We wrote about that false sense of safety in why spellcheck misses API contract changes.
What drift costs you
You will not see drift in an error log. You see it later, somewhere else:
- Support tickets that turn out to be "the docs are wrong."
- SDK samples and quickstarts that fail on the first copy and paste.
- Integrators who stop trusting the reference and start reading your source, or asking your engineers on Slack.
- Slower onboarding for new partners, because every page needs to be double-checked.
Each fix is small. The cost comes from finding the problem weeks after the change that caused it, when nobody remembers why the parameter was renamed.
Tools that catch part of the problem
Several common checks touch documentation. Each one answers a real question. None of them answers "does this page still match the API?"
| Check | What it catches | What it misses |
|---|---|---|
| Link checker | Dead links and missing pages | A live page that describes the wrong endpoint |
| Spellcheck and prose linters | Typos, style, terminology | Correctly spelled parameters that no longer exist |
| OpenAPI linter or validator | An invalid or badly structured spec | Markdown guides that disagree with a valid spec |
| Breaking-change diff (for example oasdiff) | Changes between two spec versions that could break clients | Which guides and examples still describe the old version |
| Docs-to-code drift check | Docs that disagree with routes, parameters, schemas, and examples | Prose quality and broken external links (keep your other tools) |
These tools are complementary. Keep your link checker and your spec validation. The gap is the comparison between the written docs and the contract. There is more on that split in OpenAPI validation is not a link checker.
How to catch drift in the pull request
The cheapest moment to fix a stale page is the pull request that made it stale. The author still has the context, and the fix is one more commit. Here is a workable process:
- Pick your sources of truth. Usually the route handlers and the OpenAPI file. The Markdown/MDX docs are what gets checked against them.
- Run the check on every pull request that touches routes, the spec, or the docs. Not in a quarterly audit.
- Require evidence on both sides. A finding should name the file and line, quote what the docs say, and show what the code or spec says.
- Decide what blocks the merge. A removed endpoint that is still documented should probably fail. A missing example might only warn.
- Keep fixes as suggestions. Let a tool draft the corrected paragraph, but have a person accept it.
The full workflow is in catch outdated API docs in the pull request.
What a useful drift finding looks like
A score with no evidence is easy to ignore. A mismatch that shows both sides of the contract is not. An illustrative finding:
Endpoint mismatch (error)
docs/api/users.md:14
Docs say: GET /api/users/{id}
Code says: GET /api/v2/users/{userId} (openapi.yaml, operationId getUser)
Why: The documented path and path parameter no longer exist.
Suggested: Update the path to /api/v2/users/{userId} and rename the parameter.
The detection should be deterministic: a parser compares the docs to the spec and code and either finds a mismatch or does not. A language model is useful for explaining the mismatch and drafting the sentence a reviewer can accept. It should not be the thing that decides the docs are wrong. We explain why in deterministic checks versus an AI documentation review.
Where LintDrift fits
LintDrift runs this comparison on GitHub pull requests. It installs as a GitHub App, finds your docs directories, Markdown, MDX, and OpenAPI specs, and checks the pull request against the contract for the six drift types above.
Findings show up as a GitHub Check Run with severity, file, line, the docs side, the code side, and a suggested correction. You choose which severities fail the check. Detection is deterministic. AI explains the finding and drafts the fix, and nothing is applied until someone accepts it.
Today it supports TypeScript/Node repositories with OpenAPI and Markdown/MDX on GitHub. The Free plan covers one repository. See plans and pricing.
FAQ
What is the difference between documentation drift and spec drift?
Spec drift is when your OpenAPI file no longer matches the code. Documentation drift is when your written docs, guides, and examples no longer match the spec or the code. You can have a perfect spec and still have drifted docs.
Can a link checker detect API documentation drift?
Only one small part of it. A link checker finds links that point nowhere. It cannot tell that a working page describes a parameter you renamed last week.
Does generating docs from OpenAPI prevent drift?
It prevents drift in the generated reference pages, as long as the spec is correct. It does not cover hand-written guides, tutorials, migration notes, or code examples, which is where most customer-facing drift lives.
Can AI detect documentation drift on its own?
A model can read docs and code and guess at mismatches, but the result is hard to verify and can change between runs. A deterministic comparison is more reliable for deciding that something is wrong. AI is better used to explain the finding and draft the fix.
How often should we check for drift?
On every pull request that changes routes, the OpenAPI spec, or the docs. Periodic audits find drift weeks late, after customers have already hit it.
Which stacks does LintDrift support?
TypeScript/Node repositories on GitHub that use OpenAPI and Markdown or MDX docs. Other languages and Git hosts are not supported yet.
If the reference your customers integrate against can change without a failing check, your docs are already free to drift. Start with the Free plan on one repository.
Catch the next outdated endpoint before it merges.