Point it at an OpenAPI spec and get a real, running mock API in one command. Zero config, single Go binary, schema-valid responses — for when the backend you need isn't ready, is flaky, or costs money to call.
Every time I build something that talks to an API that isn't ready yet — or is flaky, or rate-limited, or a paid third party I can't hammer in CI — I end up doing the same tedious thing: hand-rolling a fake version of it. Hardcoded JSON in the app, a throwaway Express/Flask stub, or a pile of WireMock config. I redo it every feature, and the fake always drifts from the real API.
mocksmith kills that busywork. Give it your OpenAPI spec and it stands up a real HTTP server that answers every endpoint with schema-valid data:
mocksmith openapi.json
# mocksmith serving 6 path(s) on :8080$ curl localhost:8080/pets/7
{
"id": 1,
"name": "string",
"status": "available",
"email": "user@example.com",
"createdAt": "2024-01-01T00:00:00Z"
}Because it's a running server your app connects to, not an answer you paste. You can't develop a frontend against a chat window. mocksmith is the thing in the other terminal that behaves like the backend — and it drops into CI so your tests never hit a real or paid API.
go install github.com/jay-tank/mocksmith@latest
# or clone + build:
git clone https://github.com/jay-tank/mocksmith.git && cd mocksmith && go build -o mocksmith .Single static binary, no runtime dependencies.
mocksmith openapi.json # serve on :8080
mocksmith --addr :9000 openapi.json # pick a port
mocksmith --latency 200ms openapi.json # simulate a slow backend
mocksmith --error-rate 0.1 openapi.json # 10% of requests return an injected 500- Schema-valid responses — it reads each endpoint's response schema and returns a
matching body, honoring
$ref, enums (first value), and stringformat(email,uuid,date-time, …). Explicitexamples in the spec are used as-is. - Path params —
/pets/{id}matches/pets/7. - Latency & error injection — test your timeouts, retries, and error handling without touching the real service.
See docs/USAGE.md.
- v0.1 reads JSON OpenAPI 3 specs. That keeps the binary dependency-free. YAML support is the top roadmap item (convert with any yaml→json tool in the meantime).
- It returns representative data, not a stateful backend — a POST doesn't actually create anything you can GET back later. It's for developing and testing against shapes, not a real database.
- Realistic AI-generated sample data (names, addresses, believable values instead of
"string") is on the roadmap; today's data is deterministic and type/format-based.
There are heavier tools in this space (WireMock, Prism); mocksmith's niche is one Go binary, zero config, instant.
MIT — see LICENSE.