API Contract Testing

Validates API contracts using OpenAPI specs, Pact consumer-driven tests, and JSON Schema.

Updated Jul 16, 2026
One-click install
npx skills add https://github.com/pjherron/hypoc --skill api-contract-testing-pjherron
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: API Contract Testing
Source: https://github.com/pjherron/hypoc/tree/main/hypoc/skills/api-contract-testing
Command: npx skills add https://github.com/pjherron/hypoc --skill api-contract-testing-pjherron

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? APIs break silently when providers change responses, remove fields, or alter types, and traditional integration tests are slow and brittle. This Skill catches breaking changes before deployment and enables independent service deployment through contract-first development and consumer-driven contract testing. ## Core Features & Use Cases - OpenAPI/Swagger Validation: Validate requests and responses against OpenAPI specs, detect breaking changes between spec versions, and auto-generate tests with Schemathesis. - Pact Consumer-Driven Contracts: Define expected interactions on the consumer side and verify providers can satisfy them, with state handlers and broker-based can-i-deploy checks. - JSON Schema & Mocking: Runtime validation with Ajv, mock services with MSW or WireMock, and contract-aware load testing with k6. - Use Case: A team shipping a microservices API adds contract tests to CI so a PR that removes a required field from the users endpoint fails the breaking-change check before merge. ## Quick Start Set up contract tests for my REST API by validating responses against my openapi.yaml spec and adding a breaking-change check to CI.

Frequently Asked Questions about API Contract Testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test API contracts with OpenAPI?▼

Validate requests and responses against your OpenAPI spec using openapi-backend in Node.js or Schemathesis in Python. Schemathesis auto-generates tests for all endpoints and checks status codes, schemas, and undocumented errors.

What is the difference between contract testing and integration testing?▼

Contract testing validates only the API interface using mock providers, making it fast and suitable for pre-deployment checks. Integration testing runs real services end-to-end, validating business logic but running slower and breaking more easily.

How do I detect breaking changes in an OpenAPI spec?▼

Use openapi-diff to compare the old and new spec versions and flag removed endpoints, removed required fields, and changed response types. Run this check in CI to block pull requests that introduce critical breaking changes.

Does Pact contract testing work with Python?▼

Yes, the pact Python library supports consumer-driven contracts with given/upon_receiving/will_respond_with syntax and matchers like Like and EachLike. Provider verification runs against the real service with state handlers that set up test data.

Why does my contract test pass but integration fails?▼

This happens when the contract does not match real provider behavior. Verify provider state handlers set up data correctly, ensure provider verification runs against the real implementation, and confirm mock servers mirror production responses.

When should I not use contract testing?▼

Contract testing does not validate business logic, database transactions, or end-to-end workflows. Use integration or end-to-end tests for those scenarios, and reserve contract tests for interface compatibility and pre-deployment validation.