Skip to main content

Mock try-out

There are three ways to see what a mock answers before a consumer depends on it, from lightest to heaviest. A GraphQL version's hosted mock is called the same way, at its /graphql URL:

WayWhereNeeds a running mock
Try it — render one request without sending itThe Scenarios and Correlation editorsNo
Hosted mock — call the version's mock URLThe Mock cell on Published or VersionsYes, turned on
GraphQL mock — query a GraphQL version, or open GraphiQLThe /graphql URL in the Mock cell on PublishedYes, turned on
Mock server test drive — a short-lived mock of a file you just exportedExport studio, Review & GenerateStarted for you, for 30 minutes

Preview a response (Try it)​

Route/ade/dashboard/published
  1. On Published, click “Scenarios” (or “Correlation”) in a version's Mock cell.
  2. Under Try it, choose an operation — GET /pets — and fill in any parameters.
  3. Click “Render”. You see the status, headers and body the mock would return, and a trace naming the layer that answered — a scenario and its rule, correlation or the spec's example.

Nothing is saved and nothing is sent: the preview uses the editor's unsaved draft, so you can try a change before Save scenarios. Latency and chaos are reported rather than applied. Details are in Mock response preview.

Try it: GET /pets rendered as HTTP 429, answered by the quota-exceeded scenario, rule 1, as an unsaved draftTry it: GET /pets rendered as HTTP 429, answered by the quota-exceeded scenario, rule 1, as an unsaved draft
Route/ade/dashboard/published

Call the hosted mock​

Turn on the version's mock on Published, copy its URL and call it. Send X-Mock-Scenario: <name> to pick a scenario:

curl https://mock.apiome.dev/acme/payments-api/2.3.1/payments
curl -H 'X-Mock-Scenario: quota-exceeded' https://mock.apiome.dev/acme/payments-api/2.3.1/payments

The Mock cell's sparkline counts the requests over 30 days. Counts reach it within a few seconds, because the mock writes them in batches.

After you turn a mock off, it can keep answering for up to 5 seconds. After you revoke an API key, private mocks can keep accepting it for up to 30 seconds. Both are the default cache times. Your administrator can change them: see The mock runtime's database work per request.

A mock starts from the version's stored OpenAPI document: the same bytes GET /v1/schema serves. Publishing a version stores that document, so starting a mock, saving its scenarios and Try it do not generate it again.

Query a GraphQL mock​

Route/ade/dashboard/published

A version imported from GraphQL SDL is mocked at one URL, which its Mock cell shows and copies in place of the base URL.

  1. On Published, turn on the GraphQL version's Mock switch.
  2. Click the copy button beside the URL ending in /graphql.
  3. Open the URL in a browser to explore the schema in GraphiQL, or send operations to it:
curl -X POST https://mock.apiome.dev/acme/people-graph/1.0.0/graphql \
-H 'Content-Type: application/json' \
-d '{"query": "{ user(id: \"1\") { id email } }"}'

Fields with declared examples return them; everything else is seeded synthetic data, the same for the same ?__seed=. Scenarios and chaos name a root field as Query.user. The note under the URL is a reminder that subscriptions are not served yet: a subscription returns an error with code UNSUPPORTED_ON_THIS_DEPLOYMENT. Limits, errors and the resolver order are in GraphQL mocks.

Published: the People Graph v1.0.0 Mock cell is on, shows its /graphql URL and notes that subscriptions are not served yetPublished: the People Graph v1.0.0 Mock cell is on, shows its /graphql URL and notes that subscriptions are not served yet
Route/ade/dashboard/published

Publish events to Kafka​

An AsyncAPI version whose mock is bound to a Kafka broker publishes its events there. It sends one message per channel every couple of seconds while the mock is on. Binding a version is done through the REST API; see Event mock brokers.

  1. On Published, check that the AsyncAPI version's Mock cell reads Events · Kafka broker bound, plus WebSocket/SSE.
  2. Point a Kafka consumer at the broker and the channel's topic. user/signedup publishes to user.signedup.
  3. To send one message right away, post to the channel's publish route. Add a JSON body to choose the payload:
curl -X POST https://mock.apiome.dev/acme/user-events/1.1.0/__channels__/user/signedup/publish \
-H 'Content-Type: application/json' \
-d '{"userId": "u-1", "email": "ada@example.com"}'

A payload that doesn't match the message schema is refused (422) and never sent. GET …/__channels__ lists each channel's topic, encoding and whether it can be published.

Test-drive an export​

Route/ade/dashboard/export/studio

After you generate an OpenAPI file in the Export studio, the Review & Generate step offers the Mock server tab under Test drive — proof that the file behaves like an API, not just that it parses.

Mock server test drive: a live base URL, a countdown, operations to send, a 200 response and the request logMock server test drive: a live base URL, a countdown, operations to send, a 200 response and the request log
Route/ade/dashboard/export/studio
  1. Click “Start mock”. The file is served as a live API for 30 minutes (the server default). Its base URL appears with “Copy URL”, a countdown — Expires in 30:00 — how many operations it has and how many requests it has served.
  2. Under Try an operation, choose a Scenario if the file declares any, fill in path parameters (for example 1 for {widgetId}) and click “Send”. The response shows its status, time and body; a body that does not match the file's own response schema is called out.
  3. The Request log states each request's outcome in words: Schema-shaped response, Matched, Body did not match the schema or No operation matched. Requests you send from your own client with curl appear here too.
  4. “Restart” gives you a fresh mock; “Stop mock” ends it early. When time is up the panel says Expired — start another to keep testing.

The panel is hidden for targets the mock engine cannot serve, and Start mock is disabled, with the reason, on a server without mock infrastructure.

With the CLI or the API​

  • CLI: apiome mock preview <project> <version> -X GET --path /pets/42 renders a request like Try it; apiome mock run BUNDLE serves a version offline — see Portable mock runtime.
  • REST: POST /v1/versions/{tenant}/{project_id}/{version_record_id}/mock/preview (Try it); POST /v1/export/{tenant}/mock, GET /v1/export/{tenant}/mock/{mock_id}/requests and DELETE /v1/export/{tenant}/mock/{mock_id} (test drive) — see the API reference.

Where next​

The Mock runtime guides cover the bundle format, fixture packs, callbacks, correlation, proxy capture, attestation and GraphQL mocks.