

Hard (spec-compliant) validation
Hard (spec-compliant) validation builds on hard validation by returning error responses whose body andContent-Type
are taken directly from your OpenAPI specification, rather than a fixed generic format.
When a request fails validation, WireMock Cloud looks up the error response declared in your spec for the relevant
status code (typically 400 or 422 for request failures, 500 for response failures).
4XX, 5XX and default response definitions are
respected.
The response body example defined for that status code is rendered as a
response template, with the following variables available:
| Variable | Description |
|---|---|
{{message}} | A human-readable summary of the validation failure, e.g. Request failed OpenAPI validation |
{{errors}} | A list of individual validation error message strings, e.g. "required property 'field' not found". Iterate with {{#each errors}}{{this}}{{/each}}. |
{{response.status}} | The HTTP status code of the error response |
{{request.method}}, {{request.path}}) are also available.
If the matched error response has a schema but no example, WireMock Cloud generates a body from the schema.
If no matching error response is defined at all, or the template fails to render, WireMock Cloud falls back to the
same generic error body used by hard validation.
Content negotiation
When the error response in your spec declares multiple media types, WireMock Cloud negotiates the responseContent-Type from the client’s Accept header, serving the matching body. If no Accept header is present,
the first declared concrete media type is used.
Error response body
In hard validation mode, an invalid request receives a JSON error response in WireMock Cloud’s standard error format. The same body is returned in hard (spec-compliant) mode whenever a spec-compliant body cannot be produced — that is, when the specification declares no matching error response, or its template fails to render. The response body matches the following schema:Validation sub-events
Whenever validation is enabled — soft, hard, or hard (spec-compliant) — each request or response that fails validation is recorded against the served request in the request log as anOpenAPI sub-event
carrying the structured failure details. In soft mode this is the only effect; the hard modes
additionally return an error response.
Each sub-event has the following form, where timeOffsetNanos is the time of the failure relative to
the start of request handling:
data object matches the following schema: