๐ OpenAPI Drift Guard โ
AI-powered API contract drift detection โ catch breaking changes between OpenAPI spec and implementation before they reach production.
Quick Links โ
- Installation โ Get started in minutes
- Quick Start โ See it in action
- API Reference โ Programmatic usage
- Skill Commands โ Interactive drift detection
The Problem โ
API specs and implementation code drift apart silently:
Spec: GET /users/{id} โ returns User
Code: GET /users/:id โ returns UserDTO (extra fields, missing id)Traditional testing catches runtime errors, but misses:
- Missing endpoints in code
- Extra undocumented endpoints
- Schema mismatches (request/response)
- Parameter type changes
The Solution โ
OpenAPI Drift Guard detects drift through three layers:
| Layer | Capability | Output |
|---|---|---|
| Spec Parsing | Parse OpenAPI/Swagger into normalized endpoints | NormalizedEndpoint[] |
| Code Analysis | Extract routes from frameworks | NormalizedEndpoint[] |
| Drift Detection | Compare and classify severity | DriftReport |
Severity Levels โ
| Severity | Meaning | Example |
|---|---|---|
| ๐ด Breaking | Will break clients | Missing endpoint, required field removed |
| ๐ก Warning | May cause issues | Optional field removed, type changed |
| ๐ข Info | Non-breaking | Extra endpoint, new optional field |
Key Features โ
๐ OpenAPI/Swagger Parsing โ
Structured parsing with zero configuration:
- OpenAPI 3.x โ JSON/YAML parsing with full schema support
- Swagger 2.0 โ Automatic normalization to OpenAPI 3.0
- $ref Resolution โ Recursive reference resolution
- Unified Model โ
NormalizedEndpointfor spec and code
๐ง Code Analysis โ
- Express/Fastify/Koa/NestJS/Hono route extraction
- TypeScript type inference for request/response
- Parameter extraction from route definitions
๐ Interactive Commands โ
In Claude Code, use natural language drift detection:
| Command | Purpose |
|---|---|
/validate <spec> <code> | Full contract validation |
/drift <endpoint> | Endpoint drift detail |
/contract <operationId> | Operation contract check |
/check-api <area> | Area batch validation |
Example Output โ
/validate openapi.yaml src/
๐ API Contract Drift Report:
๐ Spec: openapi.yaml (version 3.0.3)
๐ Impl: src/routes/*.ts
๐ด Breaking Changes (3):
1. [DELETE /users/{id}] Endpoint removed from impl
2. [POST /orders] Required field userId removed
3. [GET /products] Response type changed (string โ number)
๐ก Warnings (2):
1. [PUT /users/{id}] New constraint added: minLength(5)
2. [GET /products] Field deprecated without replacement
๐ข Info (1):
1. [GET /products] Optional field tags added
๐ Summary:
Total drifts: 6 | Breaking: 3 | Warnings: 2 | Info: 1Comparison โ
| Dimension | Schema Validation | OpenAPI Drift Guard |
|---|---|---|
| Timing | Runtime | Design time |
| Coverage | Single request | Full API surface |
| Drift Detection | โ No | โ 8 drift types |
| Code Analysis | โ No | โ Framework-aware |
| Severity Levels | โ No | โ ๐ด๐ก๐ข classification |
Get Started โ
Choose your path:
1. Claude Code Plugin (Recommended) โ
bash
/plugin marketplace add saqqdy/openapi-drift-guard
/plugin install openapi-drift-guard2. NPM Package โ
bash
pnpm add openapi-drift-guard3. CLI (Zero-Install) โ
bash
npx openapi-drift-guard validate --spec ./openapi.yaml --code ./srcProject Status โ
| Version | Theme | Status |
|---|---|---|
| v0.1.0 | Spec parsing + Express analyzer | โ Released |
| v0.2.0 | Multi-framework support | ๐ Planned |
| v0.3.0 | Claude Code Skill ready | ๐ Planned |
| v0.4.0 | CI/CD integration | ๐ Planned |
| v1.0.0 | Production-ready | ๐ Planned |
See Roadmap for details.
License โ
MIT โ use freely in personal and commercial projects.