Urgent.News

What's breaking now, across thousands of outlets.

Tech

Your OpenAPI spec is a contract. Nobody is checking it. I built a CLI that detects spec↔code drift with zero dependencies.

"The generated client keeps calling DELETE /items/{id}." "The server returns 405 Method Not Allowed." An OpenAPI spec is not just documentation. SDKs, frontend types, API docs, mock servers — everything is generated from the spec. When the implementation drifts from it, everything generated starts lying quietly . This is about oas-drift , a CLI I built that detects that drift — with zero…

Your OpenAPI specification serves as a contract governing your API's behavior. However, it often goes unchecked while codebases evolve. To address this issue, I created a command-line interface (CLI) tool called oas-drift. This tool scans both an OpenAPI JSON specification and a Python codebase to detect three types of drift: spec-only, code-only, and method mismatches.

By providing both the spec and codebase, oas-drift uncovers discrepancies that could lead to broken implementations. The CLI is lightweight, relying solely on Python's standard library, and produces a machine-readable report. The design focuses on not failing builds when drift is found, allowing for more adoption and adaptability.

The tool also pays attention to path parameters and router prefixes, ensuring literal matching between the spec and the codebase. While limited in scope (currently supporting JSON OpenAPI 3.x specs and literal path matching), oas-drift provides a read-only, deterministic method to maintain the integrity of your API contracts by detecting any drift between your specifications and code.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Saturday 19 September →