api-contract-testing

Verifies API contracts between services using consumer-driven contract tests and schema validation.

Updated Jun 22, 2026
One-click install
npx skills add https://github.com/aicodepro/ai-agent-nexi --skill api-contract-testing-aicodepro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-contract-testing
Source: https://github.com/aicodepro/ai-agent-nexi/tree/main/agent/skills/api-contract-testing
Command: npx skills add https://github.com/aicodepro/ai-agent-nexi --skill api-contract-testing-aicodepro

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Microservices break when providers change API responses without consumers knowing, and full integration test suites are slow and brittle. This Skill verifies that APIs honor their agreed contracts between consumers and providers without requiring full end-to-end integration tests. ## Core Features & Use Cases - Consumer-Driven Contract Testing: Write Pact consumer tests in TypeScript that define expected request/response interactions, then verify providers against published contracts via a Pact Broker. - Schema Validation: Validate API responses against OpenAPI specifications and JSON Schemas in Express, Python (pytest + jsonschema), and Java (REST Assured). - CI/CD Integration: Automate contract publishing, provider verification, can-i-deploy checks, and webhook-triggered verification in GitHub Actions. - Use Case: Your OrderService calls UserService. Write a Pact consumer test defining the expected user response, publish the contract to the broker, and have the provider CI verify it on every commit so breaking changes are caught before deployment. ## Quick Start Write a Pact consumer contract test for my OrderService calling the UserService GET /users/:id endpoint and show me how to verify it on the provider side.

Frequently Asked Questions about api-contract-testing

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

FAQPage Schema
How do I write a Pact consumer contract test in TypeScript?

Use PactV3 from @pact-foundation/pact to define the consumer and provider, then chain given, uponReceiving, withRequest, and willRespondWith to describe the interaction. Use MatchersV3 like string, email, and like for flexible response matching, and run assertions inside executeTest against the mock server.

What is consumer-driven contract testing for microservices?

Consumer-driven contract testing lets the consuming service define the request/response format it expects, and the provider verifies it satisfies those contracts. Tools like Pact record interactions as contract files, publish them to a broker, and verify providers without running full integration environments.

How do I validate API responses against JSON Schema in Python?

Use the jsonschema library with pytest: define schemas as dictionaries with required fields, types, formats, and enums, then call validate with the response JSON. Wrap validation in a helper class returning a boolean and error message, and use mocked responses for faster unit tests.

How does Pact Broker work in a CI/CD pipeline?

Consumers publish contracts to the Pact Broker after tests pass, and providers verify against them in their own pipeline, publishing verification results. The can-i-deploy command checks compatibility before release, and broker webhooks can trigger provider verification via GitHub repository_dispatch events when contracts change.

What should not be tested in API contract tests?

Contract tests should not cover business logic, hard-coded specific values, or internal implementation details. They validate structure and response shape using matchers, cover error responses like 404s, and check backward compatibility rather than duplicating functional test coverage.