Mocking API Responses
When your backend isn’t ready—or you want to simulate specific responses—Inspectr lets you mock APIs based on an OpenAPI specification and override responses in real time.

Inspectr leverages Stoplight Prism behind the scenes, giving you access to both static and dynamic mocking powered by Faker and JSON Schema Faker.
Want a fast demo? Jump to the Mocking Quick Start →.
Use Cases
Section titled “Use Cases”- Frontend development before backend is available
- Testing edge cases (timeouts, errors, unexpected payloads)
- Demos and offline API development
- Simulating invalid or large payloads for robustness testing
Providing OpenAPI for mocking
Section titled “Providing OpenAPI for mocking”You can provide the OpenAPI documents as a local file or as a public URL by using the --mock-backend
parameter.
Local File:
inspectr --listen=:8080 --mock-backend=./openapi.yaml
Public URL:
inspectr --listen=:8080 --mock-backend=https://inspectr.dev/demo/hello.openapi.yaml
Quick Launch OpenAPI mock
Section titled “Quick Launch OpenAPI mock”You can also launch an OpenAPI Mock using Inspectr, by just using the URL https://inspectr.dev/launch with a reference to any remote OpenAPI document:
https://inspectr.dev/launch?openapi=https://inspectr.dev/demo/hello.openapi.yaml
Replace the openapi
parameter with the URL of your own OpenAPI file. Inspectr will start immediately with mocking enabled.


You can easily mock the typical OpenAPI example APIs using Inspectr, by clicking the launch link:
-
Click here to Launch Museum API or visit https://inspectr.dev/launch?openapi=https://inspectr.dev/demo/museum.openapi.yaml
-
Click here Train Travel API or visit https://inspectr.dev/launch?openapi=https://inspectr.dev/demo/train-travel-api-openapi-source.yaml
-
Galaxy API by Scalar
Click here Galaxy API or visit https://inspectr.dev/launch?openapi=https://inspectr.dev/demo/galaxy.openapi.yaml
Static Mocking
Section titled “Static Mocking”Static mocking uses predefined examples in your OpenAPI spec to return consistent, predictable responses.
Step 1: Prepare Your OpenAPI File
Section titled “Step 1: Prepare Your OpenAPI File”paths: /items: get: responses: '200': description: Success content: application/json: examples: default: value: items: ["A", "B", "C"]
Save it as openapi.yaml
.
Step 2: Start Inspectr in Static Mock Mode
Section titled “Step 2: Start Inspectr in Static Mock Mode”inspectr --listen=:8080 --mock-backend=./openapi.yaml
- Returns mock responses based on OpenAPI examples
- No backend service needed
- Captures requests in the Inspectr UI at http://localhost:4004
Step 3: Use Response Overrides
Section titled “Step 3: Use Response Overrides”Use headers to simulate conditions or return different examples:
Header | Description |
---|---|
inspectr-response-status | Override status code (e.g. 404 , 500 ) |
inspectr-response-delay | Add artificial delay in milliseconds |
inspectr-response-example | Choose a specific OpenAPI example by name |
inspectr-response-content-type | Override Content-Type header |
Example:
Section titled “Example:”curl http://localhost:8080/items \ -H "inspectr-response-status: 404"
See the guide Response Overrides → for more examples
Dynamic Mocking
Section titled “Dynamic Mocking”Dynamic mocking generates data using Faker and JSON Schema Faker based on your OpenAPI schema and x-faker
extensions.
Step 1: Extend Your OpenAPI with x-faker
Section titled “Step 1: Extend Your OpenAPI with x-faker”components: schemas: Pet: type: object properties: id: type: integer format: int64 name: type: string x-faker: name.firstName photoUrls: type: array items: type: string x-faker: image.imageUrl
If
x-faker
is missing or invalid, Prism falls back to JSON Schema Faker.
Step 2: Start Inspectr in Dynamic Mode
Section titled “Step 2: Start Inspectr in Dynamic Mode”inspectr --mock-backend=./openapi.yaml --mock-dynamic=true
Example Response (Generated):
Section titled “Example Response (Generated):”{ "id": 12608726, "name": "Addison", "photoUrls": [ "http://lorempixel.com/640/480", "http://lorempixel.com/640/480" ]}
Comparison: Static vs. Dynamic Mocking
Section titled “Comparison: Static vs. Dynamic Mocking”Mode | Behavior |
---|---|
Static | Returns predefined examples from OpenAPI spec |
Dynamic | Generates data using Faker/JSF from schema and x-faker annotations |
Use static mode for stable mocks based on the provided examples. Use dynamic mode to simulate variability and more dynamic data.
Summary
Section titled “Summary”Mock mode in Inspectr gives you full flexibility when developing against APIs. Whether you need consistent fixtures or random data, mocking accelerates frontend and QA workflows.