Agent Wranglers

API-46Recommended

Test the API against its contract

Run tests that send requests and validate every response against the contract.

How to do it

Use a contract testing tool, such as Schemathesis or a validating proxy such as Prism, or validate responses in your own end-to-end tests. Run them in the build before every deploy. An endpoint that follows an outside protocol, such as MCP or JSON-RPC, uses that protocol's schema as its contract instead.

Examples

Shell example

schemathesis run openapi.yaml --url https://staging.example.com --checks all

How to check

Change a field's type in the code on a branch. The contract tests fail.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/api-design/contracts-and-docs/contract-tests">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.