Gate: contract-tested
Every API unit has a contract scenario and a contract test that validates it against the project’s OpenAPI document.
| Property | Value |
|---|---|
| Checker | contract-tested |
| Confronts | code |
| Blocking by default — new project | yes |
| Blocking by default — existing project | no — informs |
How it measures
Section titled “How it measures”The project’s OpenAPI is compiled from the specs of its API units (anchors docs build), so it says
what the API promises. A contract test is what says the implementation keeps it: each language has
the tool that runs requests against an OpenAPI document and validates the answers — Schemathesis or
Dredd for any stack, kin-openapi in Go, jest-openapi in JavaScript, openapi-core in Python,
swagger-request-validator in Java. Anchors does not choose the tool; it asks for the three things that
make the proof traceable: the contract scenario {CODE}-CT in the unit’s feature, with the project’s
contract regime; a test of the unit that names {CODE}-CT; and that test loading the OpenAPI
document, so it validates against the compiled contract and not against a copy written in the test.
It runs on the API unit’s main code file — the layers the project tags interface — and reads the
spec beside it; a spec with no Endpoint section is no API unit.
Declaring it
Section titled “Declaring it”gates: - name: contract-tested on: [code] check: contract-tested