API tools

OpenAPI mock generatorRequest and response fixtures

Choose an operation and body, then generate a validated JSON sample.

OpenAPI mock generator

OpenAPI specification

Generated instances

Your specification and payloads stay in this browser; no API request is sent.

Generation options

1 JSON sample keeps its body shape; batches use an outer array. JSONL stores one body per line.

Reading operations…

Use the OpenAPI mock generator when frontend tests need the shape of an API response before the endpoint is ready. Keep the contract beside the fixture so a status-code change does not quietly leave a success payload in an error test.

Generate JSON examples from OpenAPI without installing a mock server. The selected operation determines the body schema; quantity controls independent payloads, not the number of elements inside a response array.

Why use this OpenAPI mock generator

Keep error cases attached to their contract

The OpenAPI mock generator lets you choose a declared 400 response just as directly as 200. Switch between named examples to test different documented outcomes without editing the definition or remembering which payload belongs to which status.

One operation branches into distinct response cards, with one example selected.

Repeat the same fixture batch

Turn off example priority to explore the supported schema with a fixed seed. Identical input and options produce the same batch for a given engine version; a seed change never invents extra variety in an explicit constant or example.

Two matching seed inputs lead to identical ordered batches of colored payload cards.

Three choices that change the payload

01

Separate request bodies from responses

The initial YAML example is parsed into selectors automatically. Choose request to generate requestBody only; response uses the selected status and media type. Parameters in the URL, query or headers are outside this body-only workflow.

02

Decide whether examples should win

Named media examples have priority over schema and property examples. Disable example priority for synthetic data. An invalid example stops generation instead of silently falling back, so fix it or deliberately switch to schema sampling.

03

Understand the export shape

One JSON sample keeps its original body shape. A batch adds an outer array; JSONL puts one complete body on each line. Ctrl/Cmd + Enter generates manually, and changing a selector disables exports until the next successful run.

Build fixtures for specific API outcomes

Declared operation and status selection

Inspect each method and path, select a request or response, and choose any declared numeric response, range or default. The initial choice favors 200, another 2xx response, then the first available entry. Mock API responses need not all be success cases.

Examples with a validation gate

Media example values, named examples and same-document Example Object references are supported. Root and nested schema examples are used when enabled and applicable. Every exported payload is checked against the supported schema after request/response field filtering.

Direction-aware fields

Request samples exclude readOnly properties; response samples exclude writeOnly properties. Their required entries are removed for that direction. Supplied examples containing an excluded property fail rather than being rewritten behind your back.

Seeded batches

Create 1–100 independent payloads for OpenAPI test data. The OpenAPI mock data generator shares its bounded sampler with the schema tool. Seed and count are explicit; uniqueItems applies within each payload array, not across the whole batch.

Supported contracts and explicit limits

OpenAPI 3 body scope
Accepts OpenAPI 3.0.x and 3.1.x in one JSON or YAML document. Swagger 2 and OpenAPI 3.2 are not supported. Only application/json and application/*+json bodies are generated; XML, forms, binary, callbacks and webhook workflows are excluded.
A supported schema is required
Types, enum/const, properties, required, additionalProperties, items, uniqueItems and numeric or size bounds are supported. OpenAPI 3.0 nullable and exclusive bounds are normalized. Composition, conditions, pattern, format, multipleOf, tuples and unknown validation keywords stop generation, even when examples exist.
References stay inside one document
Local JSON Pointer references can target schemas or examples. External URLs, externalValue, anchors, scoped IDs, dynamic references and cycles cannot be expanded. Assertion siblings next to a 3.1 schema reference are rejected instead of being merged incorrectly.
No fabricated empty responses
A response without content produces a no-body status and no downloadable payload. A JSON media entry without schema fails explicitly. The tool does not treat default as an example, infer realistic names from property names or execute extension scripts.
Bounded generation
Input is limited to 500,000 characters. Expanded generation schemas are limited to 100,000 characters, 2,000 syntax nodes and depth 12, including containers. Strings reach 1,000 units, collections 100 entries, output 1,000,000 characters, and the worker 5 seconds. Seeds are unsigned 32-bit integers; unsafe numeric precision, duplicate keys and YAML aliases are rejected.
Data files, not a running API
No endpoint URL, HTTP listener, authentication, persistent CRUD, MSW or Express source is produced. Generation is not a contract test against a real server. A budget failure means this sampler found no result within its limits, not that the schema has no possible valid instance.

OpenAPI mock generator FAQ

How can I generate JSON examples from an OpenAPI definition?

Paste the complete supported document and select the operation, direction and media type. Keep example priority enabled for documented payloads, or disable it to sample the schema. A standalone schema belongs in the dedicated schema data generator.

How do I choose a particular response example?

Select the response status and JSON media type first, then choose its named example. Inline example values and local Example Object references are accepted. Media examples take precedence over schema examples; examples from another status are never mixed in.

Can I generate error responses?

Yes, when the operation declares a matching response with a supported JSON schema. Select 400, 404 or another declared status. This creates that body as a fixture; it does not send an HTTP response or simulate a server failure.

Why do I get the same output every time?

The default seed is 42. Keeping the document and options fixed reproduces schema sampling, while explicit examples, const and single-value enums can remain unchanged for every seed. Disable example priority before expecting seed-dependent variation.

Does the generated mock validate real requests?

No. Validation checks the supplied or generated body against the supported effective schema. It does not contact an API, execute middleware or verify HTTP headers, authentication and business rules.

See a constraint we should support?

Prepare a fixture for the next test

Start with one payload in the OpenAPI mock generator, inspect its source and status selection, then increase the count only when the test needs a batch.