Here's a scenario that plays out on engineering teams every day.
A developer is onboarding to a new project. They find the API docs and start building. Two days later, they open a pull request and get a comment: "That endpoint was deprecated three months ago. We use /v2/users/me now." The docs weren't wrong when they were written. They just weren't maintained.
This isn't a process failure. It's a structural one. Documentation written after code exists in a different place, in a different format, maintained by different people, with different incentives. Of course it drifts.
The Root Cause: Documentation Is Treated as a Deliverable, Not a Constraint
Most teams think of documentation as something you write at the end of a feature — after the code is merged, after QA is done, when someone has a moment. That sequencing guarantees the docs will lag reality.
The alternative isn't to demand developers write better docs in their free time. It's to make documentation a first-class artifact that precedes implementation — not a postscript to it.
The tool that enables this for APIs is the OpenAPI Specification. An OpenAPI spec is machine-readable, version-controllable, and the single source of truth for your API contract. When it lives in your repo alongside your code, it gets reviewed in pull requests. Linters flag when implementation diverges from spec. Mock servers let frontend teams build against the spec before the backend ships.
But here's the problem: writing OpenAPI specs by hand is tedious enough that most teams skip it — or write a minimal version and never expand it.
Why OpenAPI Specs Stay Incomplete
OpenAPI 3.1 is comprehensive. That's part of the problem. A production-quality spec needs:
- Complete schema definitions with proper types, formats, and constraints
- All response variants: success, validation errors, auth errors, rate limits
- Security scheme definitions
- Parameter documentation for query, path, and header values
- Pagination patterns
- Clear
operationIdnaming for code generation
Writing this for a moderately complex API with 20+ endpoints can take a full day. And that day isn't available at the start of a project, when architecture decisions are still being made. So teams write a skeleton spec, or use something like Swagger annotations inline in code (which creates coupling and is equally hard to keep current), or skip it entirely.
The Spec Generator Approach
A newer approach uses AI to generate an OpenAPI spec directly from a plain-English description of what an API should do. Instead of translating requirements → code → annotations → spec, you go directly from requirements → spec → code.
Here's what that looks like in practice with 8sprint:
You describe your API in a paragraph or two:
"I need an e-commerce API with products, categories, orders, and customers. Products belong to categories. Orders have line items and status tracking (pending, confirmed, shipped, delivered, cancelled). Customers have addresses. I need filtering and sorting on the product list, and authentication for the order and customer endpoints."
8sprint routes this through specialized AI agents and produces a complete OpenAPI 3.1 spec in under 3 minutes. Here's part of the orders section:
paths:
/orders:
post:
operationId: createOrder
summary: Create a new order
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [customerId, lineItems]
properties:
customerId:
type: string
format: uuid
lineItems:
type: array
minItems: 1
items:
type: object
required: [productId, quantity]
properties:
productId:
type: string
format: uuid
quantity:
type: integer
minimum: 1
responses:
'201':
description: Order created
content:
application/json:
schema:
$ref: '#/components/schemas/Order'
'400':
description: Validation error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
'401':
description: Unauthorized
'422':
description: Business rule violation (e.g., product out of stock)
This level of detail — validation rules, multiple response codes, proper schema references — takes experience and discipline to write manually. The AI generates it as a baseline you can review and adjust.
How This Fixes the Documentation Drift Problem
When you start with a generated spec and treat it as the source of truth:
Implementation follows the spec, not the other way around. Backend developers implement what the spec defines. Frontend developers mock against it. Both sides know what to expect.
The spec lives in version control. Changes to the API require changes to the spec — reviewed in pull requests like any other code change.
Tooling enforces the contract. Libraries like openapi-enforcer, dredd, or Prism can run contract tests in CI, failing a build if the implementation diverges from the spec.
Onboarding uses accurate documentation. Because the spec was accurate at implementation time and maintained through review, new developers start with a reliable reference.
The Practical Starting Point
You don't need to overhaul your entire development process to benefit from this. The practical starting point:
- Use a tool like 8sprint to generate a spec from your project description
- Review it for correctness — adjust any details the AI misunderstood
- Commit it to your repository as the starting point for implementation
- Add a linter (like
redocly lintorspectral) to your CI pipeline to catch spec regressions
The spec won't stay perfect automatically. But it starts from a better position than "we'll document this later," and review tooling makes drift visible instead of invisible.
Start with a Spec, Not a Wish
Documentation isn't out of date because developers are lazy or disorganized. It's out of date because it's written after the fact, in a format that's separate from the code, with no automated enforcement keeping it honest.
Starting with an OpenAPI spec — generated from your requirements before you write a line of implementation — inverts the problem. Documentation becomes a constraint that the implementation must satisfy, not a record of what the implementation happened to do.
Generate your OpenAPI spec from a description at 8sprint.com →
Free tier: 3 generations/month. No credit card required.
8sprint is an AI documentation platform that generates OpenAPI 3.1 specs, Prisma schemas, architecture diagrams, and 15+ supporting docs from a plain-English project description.
Top comments (0)