What this OpenAPI tool does
Frontend work often starts before the backend is ready, and hand-writing types for an API that already has a spec is wasted effort. Paste an OpenAPI 3.x or Swagger 2.0 document in JSON or YAML and this tool generates three things: realistic mock responses for every operation, TypeScript types for all schemas, and a small typed fetch client with one function per endpoint. Everything is generated in your browser, so private or internal API specs are never uploaded.
How to use it
- Paste your spec or upload the file. Both JSON and YAML are accepted.
- The endpoint list shows every operation with its method and path.
- Open the mock data tab and select an operation to see a sample response, built from schema examples, formats and enums.
- Switch to TS types for interfaces generated from
components/schemas(ordefinitionsin Swagger 2). - Switch to TS client for a ready-to-use client and copy it into your project.
How mocks are generated
exampleandexamplesvalues from the spec always win.enumpicks the first value;defaultis respected.- String formats produce plausible values:
email,uuid,date-time,uri,ipv4and so on. - Property names give hints, so
name,priceorcreatedAtlook realistic. $ref,allOf,oneOfandanyOfare resolved; recursive references are cut off safely.- Mocks are deterministic per operation, so they don't change on every refresh.
Using the generated client
The client exports a BASE_URL constant and one async function per operation, named after its operationId (or method and path when missing), with typed path parameters, query parameters and request body, returning the typed response. It only depends on fetch, so it works in browsers, Node 18+, Deno and Bun.