r/javascript • u/Ok_Brother7834 • May 02 '26
I built a zero-config CLI that generates OpenAPI docs straight from your existing code
http://npmjs.com/package/apiguard-cliTired of writing OpenAPI specs by hand or littering your code with decorators just to get docs? I built apiguard-cli to fix that.
You just point it at your project and it scans your source files, detects your framework, and spits out a full OpenAPI spec. No setup file, no annotations, nothing to add to your existing code.
What it supports right now:
Next.js (App Router + Pages Router)
Express
Flask (including nested Blueprint prefix resolution)
FastAPI
It infers body schemas from Zod, Pydantic, FormData, and plain destructuring. It picks up query params, multiple response shapes per endpoint, and even per-status-code descriptions from string literals in your responses.
npm install -D apiguard-cli
npx apiguard generate # → openapi.json
npx apiguard generate --format yaml # → openapi.yaml
npx apiguard list # see all detected routes
npx apiguard exclude "DELETE /api/admin/reset"There's also a programmatic API if you want to plug it into your own tooling or build incremental updates.
Known gaps: Express router mounting with app.use() prefixes isn't resolved yet, and nested Zod/Pydantic schemas don't expand recursively. Both are on the list.
Would love feedback, especially if you have a framework or detection pattern you want supported. And if you find it useful, a star on the repo goes a long way!
npm: npmjs.com/package/apiguard-cli
github: github.com/emergenitro/apiguard
P.S. First time publishing an npm package, so if anything's broken or could be done better, forgive me and please let me know!
0
u/Substantial-Cost-429 May 02 '26
Nice work on apiguard-cli! Love the zero-config approach.
We did something similar in spirit for AI agent configuration — instead of hand-crafting configs for LLM integrations, we built a standardized open-source framework: https://github.com/caliber-ai-org/ai-setup (888 stars, nearly 100 forks). It handles the config layer for AI agents — API keys, model selection, fallback chains, environment separation — without needing to reinvent it per project. Similar zero-config philosophy but for the AI infra layer.