All Posts
OpenAPISwaggerMock APIs

Turn a Swagger or OpenAPI File Into a Live Mock API in 60 Seconds

Kiran MayeeJuly 20, 20255 min read

If your team follows a spec-first API design process, you're already sitting on everything you need to generate a live mock. The spec describes every route, every request parameter, every response schema. A good mock platform reads that spec and serves HTTP responses — no code required from you.

Step 1: Prepare Your Spec

moqapi.dev accepts OpenAPI 3.x (YAML or JSON) and Swagger 2.0. Your spec needs:

  • paths — at least one defined path and method.
  • Response schemas under components/schemas or inline — this drives data generation.
  • Response status codes — 200, 201, 404, etc. so the platform knows what shape each response has.

If your spec is missing schemas, responses will still be served — but they'll be empty objects. Add schema references for the richest mock data.

Step 2: Import

In moqapi.dev, navigate to Mock APIs → Import YAML (Spec). You can:

  • Paste a public spec URL (Petstore, any GitHub raw URL, Stoplight-hosted specs).
  • Upload a local file.
  • Paste raw YAML or JSON directly into the editor.

Hit Import. The platform parses the spec, creates a mock API entry, and activates all routes.

Step 3: Call Your Mock

# Your base URL after import
https://moqapi.dev/api/invoke/mock/<your-api-id>

# The spec defines GET /pets — call it:
curl https://moqapi.dev/api/invoke/mock/<your-api-id>/pets

# Parameterised routes work too:
curl https://moqapi.dev/api/invoke/mock/<your-api-id>/pets/42

# Query filters are respected:
curl "https://moqapi.dev/api/invoke/mock/<your-api-id>/pets?status=available"

What Gets Generated Automatically

  • Response bodies — populated from your schemas using Faker.js with field-name heuristics.
  • Status codes — returns the first 2xx defined in your spec by default; can return error codes on demand.
  • Content-Type headers — set from your spec's produces / content declarations.
  • Array responses — returns a realistic list (default 5–12 items) when your schema type is array.

Spec Versioning

Every time you import a new version of your spec, moqapi.dev stores it with a version number and timestamp. You can activate any version instantly, compare diffs, and roll back if a spec change breaks consumers. Share the mock URL with your team — it stays stable across versions.

60 Seconds Is Not a Marketing Claim

The Petstore import takes less than five seconds. Parsing a complex real-world spec with 80+ endpoints takes under 30. The remaining 30 seconds are yours to write the first curl command. This is truly the fastest path from a spec file to a working API endpoint.

Share this article:

About the Author

Kiran Mayee

Founder and sole developer of moqapi.dev. Full-stack engineer with deep experience in API platforms, serverless runtimes, and developer tooling. Built moqapi to solve the mock data and deployment friction she experienced firsthand building production APIs.

Ready to build?

Start deploying serverless functions in under a minute.

Get Started Free