← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

OpenAPI / Swagger Specification

Architecture Intermediate
debt(d7/e7/b5/t5)
d7 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'only careful code review or runtime testing' (d7). Spectral can lint an existing spec for structural issues, but the core misuse patterns — spec drifting from implementation, missing error schemas, no runtime validation — are not caught by linting tools alone. The absence of an OpenAPI spec, or a spec that contradicts the actual implementation, is typically only discovered through manual code review, integration tests, or when consumers hit undocumented behaviour in production.

e7 Effort Remediation debt — work required to fix once spotted

Closest to 'cross-cutting refactor across the codebase' (e7). The quick_fix describes a broad adoption task: defining the API with OpenAPI 3.x, wiring validation middleware, and generating client SDKs. Remediating drift (docs written after the fact, missing $refs, missing error schemas, absent runtime validation) requires touching API route definitions, middleware configuration, schema libraries, and potentially CI pipelines across the codebase — well beyond a single-file fix.

b5 Burden Structural debt — long-term weight of choosing wrong

Closest to 'persistent productivity tax' (b5). OpenAPI applies to web/API contexts. A well-adopted spec becomes load-bearing (drives codegen, mocking, contract testing), but the misuse patterns (manual docs, spec drift, no validation) impose an ongoing tax on every change: developers must keep docs in sync, resolve drift, and manage the gap between spec and reality — slowing multiple work streams without necessarily defining the system's shape.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap' (t5). The misconception is clearly documented: developers treat OpenAPI as static documentation rather than a living, tooling-driving artifact. This is a widely encountered gotcha — most developers eventually learn that the real value is in codegen, contract testing, and runtime validation, not just readable docs. It's a notable but well-known trap, not one that catastrophically contradicts developer intuitions from other ecosystems.

About DEBT scoring →

Also Known As

OpenAPI Specification Swagger OAS API spec

TL;DR

A machine-readable YAML/JSON description of a REST API — enabling auto-generated documentation, client SDKs, mock servers, and contract testing.

Explanation

OpenAPI (formerly Swagger) is the standard for describing REST APIs in YAML or JSON: endpoints, parameters, request/response schemas, authentication methods, and error codes. An OpenAPI spec enables: Swagger UI interactive documentation, auto-generated client SDKs, contract testing (Dredd, Schemathesis), and mock servers for frontend development against a not-yet-built backend. PHP tools include zircote/swagger-php (annotation-based generation from docblocks), API Platform (spec-first approach), and league/openapi-psr7-validator for runtime request validation. Design-first (write the spec before the code) consistently produces better-structured APIs than code-first generation.

Common Misconception

OpenAPI is just API documentation. An OpenAPI spec also drives code generation for clients and servers, automated contract testing, mock servers, and validation middleware — treating it as living documentation that drives tooling is far more valuable than static docs alone.

Why It Matters

OpenAPI (Swagger) is the standard for describing REST APIs — a machine-readable spec enables auto-generated docs, client SDKs, and contract testing, making the API a verifiable artifact not just documentation.

Common Mistakes

  • Writing OpenAPI docs manually after the fact — they drift from the implementation immediately.
  • Not using $ref for shared schemas — duplicate schema definitions diverge over time.
  • Missing error response schemas — consumers cannot handle errors programmatically without them.
  • Not validating requests against the OpenAPI spec at runtime — the spec and code can contradict each other.

Code Examples

✗ Vulnerable
# OpenAPI with no error schemas — consumers can't handle errors:
paths:
  /users/{id}:
    get:
      responses:
        '200':
          content:
            application/json:
              schema: {$ref: '#/components/schemas/User'}
        # Missing 404, 422, 500 schemas — errors undocumented
✓ Fixed
# OpenAPI 3.0 spec (openapi.yaml)
openapi: 3.0.3
info:
  title: Order API
  version: '2.0'
paths:
  /orders:
    post:
      summary: Place an order
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [user_id, items]
              properties:
                user_id: { type: integer }
                items:
                  type: array
                  items:
                    type: object
                    required: [product_id, quantity]
                    properties:
                      product_id: { type: integer }
                      quantity:   { type: integer, minimum: 1 }
      responses:
        '201': { description: Order created }
        '422': { description: Validation error }

# Generate PHP client:
$ openapi-generator generate -i openapi.yaml -g php -o client/

Added 15 Mar 2026
Edited 22 Mar 2026
Views 74
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 6 pings T 11 pings F 0 pings S 0 pings S 0 pings M 0 pings T 2 pings W 2 pings T 0 pings F 1 ping S 2 pings S 2 pings M 2 pings T 1 ping W 0 pings T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 1 ping F 0 pings S 0 pings S 2 pings M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Ahrefs 19 Amazonbot 10 Scrapy 9 Google 5 ChatGPT 5 SEMrush 5 Perplexity 3 Unknown AI 2 Claude 2 Bing 2 PetalBot 2 Meta AI 1 Majestic 1 Sogou 1
crawler 62 crawler_json 5
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Medium
⚡ Quick Fix
Define your API with OpenAPI 3.x — generate interactive docs with Swagger UI, validate requests/responses with middleware, and generate client SDKs automatically
📦 Applies To
any web api laravel symfony
🔗 Prerequisites
🔍 Detection Hints
No openapi.yaml or openapi.json in project; API documentation in README or Postman only; no request validation against schema
Auto-detectable: ✓ Yes spectral swagger-php redoc swagger-ui
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Low ✗ Manual fix Fix: Medium Context: File


✓ schema.org compliant