Sandbox with Wiremock
The newer APIs have their sandbox endpoints built using Wiremock as the tool. This allows for faster creation and updating of sandbox APIs and greater flexibility in the features we can implement through stubs.
Stubs
A stub is a set of specifications that the server uses to mock a request and a response that the server is able to process.
A stub consists of:
- Request
- A path that receives the request;
- Headers and their values;
- The expected verb for that path;
- An OpenAPI Specification with the expected body, when needed.
- Response
- A response header
- A response code
- A response body
This specification is then processed and served as a REST API.
Wiremock-specific response
When an HTTP request reaches the server, Wiremock looks for a matching stub, validating the headers and the payload. If a matching stub is found, the response is the one specified in the stub (and, consequently, in the product documentation in the API reference).
If no matching stub is found — either because it lacks the specified headers or because the body does not conform to the documentation — Wiremock returns 404 - Not Found and a text/plain payload containing the closest stub found, with the divergence marked with does not match.
