Mock an API from its OpenAPI spec before it's built
API-first teams write the OpenAPI spec before the code. The frontend and mobile developers then wait for the backend, or write their own fake server. With a mock server built from the spec, they can start the same day, against the URLs and shapes they'll get later.
1. Import the spec
In the Collections sidebar, Import → Import file… (or Import from URL for a spec that's published somewhere). Pick the file and check the preview: one folder per tag, one request per operation, the first server as {{baseUrl}}, path parameters as {{name}}, and bodies filled from examples or the schema.
From a terminal:
requestarium import ./openapi.yaml --name "Orders API" --environments--environments creates one environment per server listed in the spec. See from OpenAPI spec to a working collection for the details of the import.
2. Check the examples
Response examples in the spec become saved examples on each request. Open a request's Docs tab: they're listed under Example responses, with their status codes.
A spec with good examples gives you a useful mock straight away:
responses:
'200':
content:
application/json:
example:
id: ord_42
status: paid
total: 4200
'404':
content:
application/json:
example:
error: not_found
message: Order not foundIf an operation has no examples in the spec, its request has none either, and the mock answers 404 for it. Add examples to the spec (the better fix, since docs benefit too) and import it again into the same collection, or send the request to a prototype or a stub and use Save as example on the response.
3. Create the mock server
Select the collection, open its Mocks tab, enter a name and press Create mock server. Copy the URL, or the ready curl command:
curl https://mock.requestarium.com/m_8f3k2x9q1z/orders/ord_42Calls match requests by method and path. {id} and {{id}} segments match any value, and the leading {{baseUrl}} of the saved URL is ignored, so GET /orders/anything matches the imported GET {{baseUrl}}/orders/{{orderId}}.
4. Use it from an environment
Create an environment Mock with:
baseUrl=https://mock.requestarium.com/m_8f3k2x9q1zRequests in the collection now go to the mock when Mock is selected, and to the real API with the other environments. The frontend does the same with its own config: one base URL to change.
Errors and edge cases
Callers pick a specific example with a header, which is how a frontend tests its error handling against a backend that doesn't exist yet:
curl -H 'x-mock-response-code: 404' https://mock.requestarium.com/m_8f3k2x9q1z/orders/ord_missingWhen the backend arrives
Run the same requests against the real staging environment, with assertions (a JSON Schema check works well). Differences between the spec's examples and the real responses show up as failures, and they're exactly the conversations to have before release.
Plans
The Free plan includes one mock per collection and 10,000 calls a month. Private mocks with a key, a response delay and larger bodies are on Pro, Team and Enterprise.