Legacy Code Night Shift: Drafting a Living API Contract with a Free Model and a Free Server
说明与用途
使用免费 LLM 自动生成 JSON Schema 并通过免费服务器进行夜间验证的工作流,能在 Flask 应用上线前及时发现 API 响应变更。
问题
Inherited a Flask app without an OpenAPI spec or contract tests, making it hard to know expected responses before refactoring.
结果
Implemented a repeatable, low-cost workflow that automatically drafts and validates API contracts, reducing refactor risk and catching payload changes before production exposure.
工作流
- 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
证据
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.
- 记录日期: 2026-09-05T18:23:00.796Z