Legacy Code Night Shift: Drafting a Living API Contract with a Free Model and a Free Server
Description and use
An automated workflow using a free LLM to draft JSON Schemas and a free server for nightly validation detects API payload changes in a Flask app before they reach production.
Problem
Inherited a Flask app without an OpenAPI spec or contract tests, making it hard to know expected responses before refactoring.
Outcome
Implemented a repeatable, low-cost workflow that automatically drafts and validates API contracts, reducing refactor risk and catching payload changes before production exposure.
Workflow
- Extract routes and view source from Flask app
- Send each route’s source to a free LLM to generate a JSON Schema
- Store generated schemas in a contracts/ folder
- Run a free server nightly to validate each endpoint against its schema and report drift
Evidence
A free model can draft that contract while you sleep, and a free server can validate it every morning.
Keep the temperature at zero. You are not asking for creative descriptions; you want deterministic output that the validator can rely on.
- Record date: 2026-09-05T18:23:00.796Z