# openapi-snapshot

> A Rust CLI that snapshots a running backend's OpenAPI spec, so coding agents integrate against the real API instead of inventing endpoints.

- Canonical: https://ashwinravikumar.com/projects/openapi-snapshot
- Role: Sole author. I wrote it and published every release.
- Language: Rust (edition 2024)
- Releases: 0.1.0 to 0.1.4 on crates.io, Dec 2025 to Jan 2026
- Licence: MIT
- Link (github.com/0xashrk/openapi-snapshot): https://github.com/0xashrk/openapi-snapshot
- Link (crates.io/crates/openapi-snapshot): https://crates.io/crates/openapi-snapshot

## What it does

Coding agents guess API endpoints and payload shapes when they cannot see the live contract. openapi-snapshot fetches the OpenAPI JSON from a running server and writes it to a file in the repo, so the agent reads the real contract instead. It works as a lightweight alternative to an MCP server: AGENTS.md or CLAUDE.md points at the snapshot, and the agent calls the API with curl.

## How it works

- It fetches the spec from a running server; it does not generate OpenAPI from code.
- It writes pretty JSON by default, with options to minify, keep only paths and components, or write a small outline.
- The watch command re-fetches every two seconds and keeps the full snapshot and the outline in sync.
- A header flag passes credentials for protected specs.

## Install and run

```
cargo install openapi-snapshot

openapi-snapshot \
  --url http://localhost:3000/api-docs/openapi.json \
  --out openapi/backend_openapi.json
```

## Where it's used

perpscreener uses it to keep its own API snapshot current.
