Day 5: We scanned a 200-route codebase into OpenAPI without uploading a file
说明与用途
使用本地 AST 扫描器 Powerduck 为拥有 200 条路由的遗留 Express 服务生成准确的 OpenAPI 文档,标记缺口供人工审核,并可选择使用 AI 进行模式建议。
问题
Reverse-engineering an accurate OpenAPI spec for a legacy 200-route Express service without uploading source code to external services.
结果
Generated a trustworthy OpenAPI spec for a legacy Express service, with explicit gap flags and optional AI assistance, enabling reliable contract reuse and reducing documentation effort to iterative rescans.
工作流
- 1. Run Powerduck desktop code scan on local repository using @powerduck/code-to-openapi engine.
- 2. Scanner performs AST walk to resolve route prefixes, parameters, and handler bindings across nested routers.
- 3. Schemas inferred from type systems (TypeScript interfaces, Pydantic models, Java DTOs, Go structs, C# records).
- 4. Engine flags gaps (e.g., body-schema-unknown, auth-unknown) instead of guessing.
- 5. Each discovered route appears in a review dialog with method, path, confidence, and gap list.
- 6. Optional AI resolver can be invoked per gap to propose schemas, awaiting human approval.
- 7. Scan writes a discovery sidecar; subsequent rescans produce diffs (new, removed, renamed routes).
- 8. Merge diffs into existing spec, preserving manual edits and descriptions.
- 9. Use the resulting spec for mocks, scenarios, documentation, and MCP server.
- 10. Repeat rescans each sprint to keep contract honest.
证据
What actually worked was a dedicated AST scanner with an explicit human review gate.
The scanner I used (Powerduck's desktop code scan, powered by the open @powerduck/code-to-openapi engine) covers eight languages…
Every discovered route lands in a review dialog with its method, reconstructed path, confidence level, and gap list.
Two properties make this safe for proprietary code. The scan runs entirely on the local machine; source is never uploaded.
- 记录日期: 2026-10-03T16:40:54.716Z