Check a request log against the contract
Before you begin
- Plan
- Included in Free, Pro and Team. How plans and limits work
- Role
- Viewer or higher.
- You need
- A project with an OpenAPI contract
Check a response that went out, as its request log stored it, against the operation it answered for, so you see whether your mock, or your real API behind it, still keeps the contract.
-
Open the project’s Request logs tab.
-
On the row of a request a mock answered, or one forwarded to your upstream, select Check against the contract.
-
If the dialog says no operation, or several, matches the request, choose one under Check against an operation you choose and select Check.
The check reads the active revision. To check against an earlier one the project keeps, choose it under Revision, such as Revision 2, and the dialog checks again. If that revision is no longer kept, the dialog says so, adds Nothing was checked. Choose another revision., and lists the revisions that are.
Result
Section titled “Result”The dialog names the request and shows a Contract check with one of the results described in Check a mock against its contract: Valid, Invalid, Incomplete or Not checked, each check with whether it passed, and each finding with where it is in the body and where its rule is in the document.
When you did not choose the operation, a line says how MockHub chose it:
| Line | The operation |
|---|---|
| The operation the answering mock is linked to now. | The one the mock that answered is linked to today, which may differ from its link when the request came in |
| The operation the request matches. | The one whose method and path match the request. An exact path wins over a path with a parameter |
The verdict is kept as the log’s latest check against that revision, which the contract’s coverage shows; nothing else changes. If it could not be kept, such as for a log deleted meanwhile, the dialog says This verdict was not kept for coverage; the result above stands.
Check the request instead
Section titled “Check the request instead”In the dialog, choose Request to check the request the log kept against the same revision, instead of the response. It shows a Request check, with the operation, the result of each part (Path, Query, Headers, Cookies, Body) and each broken rule, and says Credentials were not checked. A part logging did not keep as sent is Incomplete. See Check requests against the contract.
Which logs can be checked
Section titled “Which logs can be checked”Check against the contract is on a row only when the response is an answer to the request: a mock’s, or your upstream’s in a capture. It is not on requests no mock matched, posts to the webhook inbox, requests the mock server did not answer, responses a chaos profile injected or cut, or a 502 MockHub answered itself because it could not reach your upstream, which the row tags Upstream unreachable. A 502 your upstream sent is its answer and is checked. A capture logged before MockHub marked unreachable upstreams carries no tag, so its 502 is checked as the upstream’s.
What logging changed
Section titled “What logging changed”A check reads the response as the log stored it, and logging can change it before storing it. Tags above the response, under Request and response, say how:
| Tag | Means | The check |
|---|---|---|
| Response not stored | Log response headers and body was off | Checks the status only; everything else is Incomplete |
| Body cut short of a size | The body was longer than the plan keeps; the size is what was sent | Does not check the body |
| Body fields redacted | Fields of a captured JSON body were hidden, such as a password or a key in Body keys to redact in captures |
Checks the body and never passes it; fails it only for a problem away from the hidden fields |
| Redacted and header names | Those headers’ values were hidden by Response headers to redact | Does not check those headers, nor the content type and body when it is Content-Type |
| Headers cut short | The headers ran past 64 KiB | Does not report a required header as missing |
A part logging changed is Incomplete, never Valid or Invalid, and the notes say why. The one exception is a body with redacted fields: a problem in a part of it that nothing was hidden in, such as a number sent as a string next to a hidden token, makes it Invalid.
Limits
Section titled “Limits”- Logs written before MockHub recorded what logging changed have no tags, and their checks are conclusive about the status alone: everything else is at most Incomplete.
- A check covers one logged response, or with Request its request, at one revision. Traffic is checked as it arrives only where Report mode or background checks are on. To check many logs at once, check them in bulk.
- The workspace can run 60 checks a minute, those AI assistants run included. A bulk check counts once for each call of up to 20 checks.
- JSON and text bodies are checked. XML, schemas for other media types, and headers without a single type make the check Incomplete.