Use your OpenAPI description as the contract for a mock server: define each operation’s security, request parameters, success and error responses, and representative examples, then run Prism to serve and validate those routes. Test authenticated and unauthenticated requests, each important error status, and the client’s complete pagination loop. For tests that need precise custom matching or hand-authored responses, WireMock offers a different approach: configure request matchers and stubs rather than deriving behavior directly from the API description.
Start with the behavior your client must handle
A mock is useful when its contract and examples represent the cases the client will encounter. For each operation, describe the request parameters, security requirements, successful response, and failure responses that matter to the client. Include examples for important response codes so tests can check both status and body.
OpenAPI security requirements let you describe alternatives and combinations. Multiple Security Requirement Objects in the security list are alternatives: satisfying one is enough. Multiple schemes inside a single Security Requirement Object must all be satisfied. An empty requirement object, {}, means anonymous access is supported. This distinction lets you describe optional authentication, alternative credential methods, or operations requiring multiple credentials. See the OpenAPI Specification v3.0.4.
Mock authentication success and failure
Declare the scheme and operation requirement
Define the authentication scheme in the OpenAPI description and apply the appropriate security requirement to each operation. Add the expected unauthorized response, such as HTTP 401, with the body your client is expected to handle. Authentication belongs in the contract; an undocumented failure case is harder to test consistently.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
- 100% Satisfaction Warranty – Our servers book for waitress organization are handcrafted with elegant stitching that lasts. We take pride in offering our customers a waitress book made to exceptional quality standards. To ensure satisfaction, every waiters checkbook is backed by a 1-YEAR WARRANTY. If you are not 100% SATISFIED for any reason we will send you a replacement. No Questions Asked
- Holds up under Pressure – When you're taking orders the last thing you need is a flimsy waiter book that keeps bending. Our 8”x5” server books for waitress organization is the only one with a premium reinforced dual inner core. Providing an unmatched sturdy reliable writing surface that will last for years
- On Another Level – Halt the endless cycle of replacing your cheap thin black server book that barely lasts a week. This serving book for waitresses can become your permanent partner. Crafted with overwhelmingly strong attention to detail, the waiter checkbook offers an unparalleled value that you won’t regret investing in
- Scribble In Style – Impression is everything. You’re making a statement when you bring out this sleek vegan leather serving book. Our serving books have no logos or images and exquisite stitching for a professional feel your colleagues will envy
- Stay Calm and Collected – Whether you have 1 table or 7, organization is key. This server checkbook has 9 versatile pockets including a durable metal zipper to keep your cash secure. Stay on top of everything with this deluxe server book organizer and bring superior service to every customer
Send requests with and without credentials
With Prism, send a request that supplies the expected credentials and one that omits them. Prism validates requests against the API description, and a missing or invalid credential can take its security-validation path rather than return the ordinary success example. Its guide also describes response negotiation: select the expected status explicitly because validation or security violations can affect which response is returned. See the Prism mocking guide.
A successful mock request does not prove that production authorization is correct. The mock can check a request against the declared scheme and reproduce documented responses; it does not independently test the live identity provider or the application’s authorization policy.
Rank #2
Define and exercise error responses
Associate examples with the status codes clients handle
Document the error responses that belong to the API contract and provide suitable examples or schemas for them. Depending on the API, these might include validation failures, missing or invalid authentication, a missing resource, or a server failure. Do not assume every API should use the same error format.
Prism can select response examples by key, but its response negotiation and request validation affect the result. Exercise requests that select each important error response, and assert both the status code and body shape. Prism may return a generated problem response when validation or security failures affect response selection; that is not a substitute for documenting the error responses your client must handle. See the Prism mocking guide and its validation guide.
Rank #3
Use a stub when the test needs exact behavior
If you need to force a particular status and body for a request that would otherwise fail OpenAPI validation, a WireMock stub can match the request and return a canned response. Match on the method, URL, query, headers, authentication, cookies, or body as appropriate. Keep the stub consistent with the contract, or clearly identify the test as intentionally out of contract. WireMock documents request matching and stubbing.
Make pagination examples lead to real mock pages
Represent the whole sequence
Document the query or path parameters used to select a page and the response schema for page data. Provide stable example data for a first page and a later page, plus a cursor or continuation URL that the mock can actually serve. Then run the client’s real pagination loop, including its terminal-page behavior.
Check every link or cursor the client follows. Twilio’s Mock API Generation with Twilio’s OpenAPI Spec walkthrough warns that its example next_page_uri may be http://example.com. A client that follows that value can leave the mock route and fail instead of retrieving the next page. The continuation format is API-specific, so make the example point to a route or cursor the mock supports.
Run Prism and verify the client flows
- Describe the contract. Define the operation’s security, request parameters, success response, and the error responses client code needs to handle.
- Add status-specific examples. Associate representative success and error bodies with their intended response codes.
- Start the mock. The Prism guide documents
prism mock api.oas3.yamlfor static generation andprism mock -d api.oas3.yamlfor dynamic generation. It also documents selecting dynamic behavior for individual calls with thePreferheader when the server runs in static mode. Confirm the flags against the Prism version you have installed, since command-line documentation can change. - Exercise the important paths. Test requests with and without credentials, each error case, and successive pages. Assert status, relevant headers, body shape, and whether continuation data reaches the next mocked request.
- Add custom stubs only where needed. If a case requires detailed request matching or an exact canned response, configure a WireMock stub for that scenario.
Choose the tool based on how you author behavior
| Need | Prism | WireMock |
|---|---|---|
| Generate behavior from an OpenAPI description | Uses API-description endpoints and validation rules; can select examples or generate values from schemas. Prism mocking guide. | The reviewed WireMock documentation describes matchers and stubs; it does not establish equivalent automatic OpenAPI-driven behavior. Request matching and stubbing. |
| Match authentication and request details | Validates declared OpenAPI security and can return security-related errors. Prism mocking guide. | Supports Basic-auth matching and matching on headers and other request attributes. WireMock request matching. |
| Force a specific error status and body | Define response codes and examples, accounting for response negotiation. Prism mocking guide. | Configure a matching stub with a selected status and body. WireMock stubbing. |
| Represent multiple pages | Provide usable continuation data and a mock route for the next request; the Twilio example illustrates a continuation URL that may not work as a mock route. Twilio walkthrough. | Hand-authored matchers and responses can represent pages, but page-specific setup is needed; the reviewed documentation does not prescribe a pagination recipe. Request matching and stubbing. |
| Use a hosted, shared mock | The cited documentation establishes local Prism CLI use. Prism CLI documentation. | WireMock documents a hosted WireMock Cloud option. WireMock Cloud documentation. |
Use Prism when the OpenAPI description should drive responses and request validation. Use WireMock when tests need fine-grained matching or hand-authored stubs. Consider how much distinct page data or response state the tests need, how closely behavior must follow the contract, and whether the team needs a shared hosted environment; neither approach is established as best for every project.
Best Value
Keep the mock’s boundary clear
Passing against a mock checks the client against the mock’s contract and examples. It is not evidence that the live service, identity provider, authorization policy, or data store has been tested.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




