| Crates.io | openapi-snapshot |
| lib.rs | openapi-snapshot |
| version | 0.1.4 |
| created_at | 2025-12-28 21:46:31.220354+00 |
| updated_at | 2026-01-09 00:13:30.96764+00 |
| description | Fetch OpenAPI JSON from a running server. Lightweight MCP alternative for AI agents (Claude Code, Cursor, etc.). |
| homepage | |
| repository | https://github.com/0xashrk/openapi-snapshot |
| max_upload_size | |
| id | 2009450 |
| size | 166,033 |
[!NOTE]
"Give agents the backend contract, and they stop guessing. This tool keeps that contract current."
Fetch a running backend's OpenAPI JSON and write a readable snapshot for agents and frontend tooling.
openapi-snapshot is a small CLI that pulls a live OpenAPI JSON endpoint and writes a readable JSON file. The goal is to keep a lightweight, up-to-date backend contract that agents and frontend tooling can read without guessing.
Agents and frontend projects work best when they can see the backend contract. The snapshot file is meant to be referenced from AGENTS.md/CLAUDE.md or frontend docs so everyone (humans and tools) always has the current endpoints and schemas.
Lightweight MCP alternative: For local dev with Claude Code or similar tools, this replaces the need for a full MCP server. The agent reads your snapshot files for discovery and calls your API directly via curl — no extra protocol layer required.
Generate snapshots to a predictable path:
openapi-snapshot --out openapi/backend_openapi.json --outline-out openapi/backend_openapi.outline.json
Reference in your CLAUDE.md or AGENTS.md:
Backend endpoint details live in `openapi/`.
Use `openapi/backend_openapi.outline.json` for general details.
The agent reads the spec, discovers your endpoints, and calls them directly via curl — no MCP server needed.
openapi/backend_openapi.json).AGENTS.md or CLAUDE.md so agents always load it:Backend contract: openapi/backend_openapi.json
Backend outline: openapi/backend_openapi.outline.json
/api-docs/openapi.json).cargo install openapi-snapshot
Requires the OpenAPI URL to be reachable (server running).
Basic:
openapi-snapshot --url http://localhost:3000/api-docs/openapi.json --out openapi/backend_openapi.json
Notes:
--out to choose a path or use the defaults.Quick default (no flags):
openapi-snapshot
Defaults:
http://localhost:3000/api-docs/openapi.jsonopenapi/backend_openapi.jsonfalse (pretty JSON)If the default URL is unreachable and you're in a terminal, the CLI will prompt you for a port or full URL.
Reduce to inputs/outputs only:
openapi-snapshot --url http://localhost:3000/api-docs/openapi.json --out openapi/backend_openapi.json --reduce paths,components
Outline profile (minimal path + schema refs):
openapi-snapshot --profile outline --out openapi/backend_openapi.outline.json
Note: --reduce is not supported with --profile outline.
Generate both full and outline snapshots in one run:
openapi-snapshot --out openapi/backend_openapi.json --outline-out openapi/backend_openapi.outline.json
Add auth header:
openapi-snapshot --url http://localhost:3000/api-docs/openapi.json --out openapi/backend_openapi.json --header "Authorization: Bearer TOKEN"
Print to stdout:
openapi-snapshot --url http://localhost:3000/api-docs/openapi.json --stdout
Minified output (single line):
openapi-snapshot --minify true --out openapi/backend_openapi.min.json
Keep the file updated while you code:
openapi-snapshot watch
Defaults for watch:
http://localhost:3000/api-docs/openapi.jsonopenapi/backend_openapi.jsonopenapi/backend_openapi.outline.jsonpaths,componentsfalseIf the default URL is unreachable and you're in a terminal, watch will prompt you for a port or full URL once and continue with that value.
Override anything if needed:
openapi-snapshot watch --url http://localhost:3000/api-docs/openapi.json --out openapi/backend_openapi.json --outline-out openapi/backend_openapi.outline.json --reduce paths,components --interval-ms 2000
Outline watch:
openapi-snapshot watch --profile outline --out openapi/backend_openapi.outline.json
Disable the default outline output:
openapi-snapshot watch --no-outline
Leave it running. It refreshes the snapshot files on the interval.
If you already run your backend separately, you can skip the restart and just run the exporter on a timer or on demand:
openapi-snapshot --url http://localhost:3000/api-docs/openapi.json --out openapi/backend_openapi.json --reduce paths,components
--header for auth.Cargo.toml version.cargo test.cargo publish.