opyeb openapilab

openapilab · Output

How Mock JSON and the curl and fetch snippets are built

The order in which a schema yields a value, and how server variables, paths, headers and bodies are assembled.

Once a spec can be read, it can also produce a request. For the selected endpoint this tool builds Mock JSON for the request body and response schema, and generates a curl command and fetch() code from the same schema.

The order a mock value is chosen

OrderSchema keyExample
1examplethe author's example is used as it stands
2defaultthe default value is used
3enumthe seed picks one entry
4type + formata value matching date-time, email, uuid and similar formats
5minimum / maximum / minItemsa value inside the range and an array length

Objects fill every properties entry. Arrays produce minItems entries when given (at most three) and two otherwise. Even with nullable or null in a type array the value is filled with something non-null; to see null in a preview, put it in example.

Seeds and reproducibility

Values come from a pseudo-random sequence derived from the seed string. The same seed and schema always produce the same JSON, and a different seed produces different values under the same rules. That makes it usable as a test fixture, and the regenerate button only changes the seed.

How the snippets are assembled

Tokens and keys are placeholders, not real values. Running a snippet unchanged will fail authentication, which is expected: this tool never calls an API.

Questions

Why does the mock differ from a real response?

A schema declares ranges and formats, not data. The mock builds a value that fits the format; do not expect it to match production.

How is oneOf handled?

The first entry's schema is used, because the document alone cannot say which branch would be chosen.

Can I choose the seed?

Any number or string works, and entering the same value again reproduces the earlier mock.

In the 3.0 orders preset, pick the order creation endpoint to see the request body mock and its curl side by side.

Open the tool

Written against the OpenAPI Specification 3.1.0 (2021-02), 3.0.3 and JSON Schema 2020-12. Every example spec and host is synthetic.