OpenAPI mock servers like Prism serve responses conforming to API specs, enabling frontend development and testing without a running backend. Features include request validation, example-based responses, and dynamic schema-conformant data generation for comprehensive API simulation.
0 / 5 completed
1 / 5
What is the primary purpose of using an OpenAPI mock server during frontend development?
An OpenAPI mock server reads an OpenAPI specification and serves responses matching the defined schemas, allowing frontend teams to develop and test independently of backend implementation. Tools like Prism or Mockoon generate responses from schema examples or random data.
2 / 5
A developer uses Prism with the --validate-request flag. What does this enable?
With --validate-request, Prism acts as a validating proxy that checks incoming requests against the OpenAPI spec. Requests with missing required fields, wrong types, or invalid formats receive a 422 Unprocessable Entity response, helping catch API usage errors during development.
3 / 5
An OpenAPI spec defines multiple examples for a response. How does Prism determine which example to return?
Prism supports example selection via the Prefer: example=exampleName HTTP header. Without this header, Prism returns the first defined example. This allows clients to simulate different scenarios (success, empty result, error states) by sending different Prefer headers.
4 / 5
Which strategy does a mock server use when no example is defined in the OpenAPI spec for a response?
When no example is provided, OpenAPI mock servers like Prism use dynamic generation to create random data that conforms to the response's JSON Schema. String fields get random strings, numbers get random values within defined ranges, and required/optional fields are respected.
5 / 5
A team uses OpenAPI mock testing in their CI pipeline by running Prism and executing end-to-end tests against it. What limitation should they be aware of?
OpenAPI mock servers provide schema-valid but stateless responses. They don't implement real business logic — creating a resource doesn't make it retrievable in a subsequent GET, and server-side validation rules aren't enforced. Mock tests verify API contract compliance, not application behavior.