api-contract-testing-pattern
CommunityCatch API drift with schema and snapshot tests
Software Engineering#pytest#fastapi#api contract testing#openapi snapshot#pydantic schema validation#route regression#api drift detection
Authorsaintgo7
Version1.0.0
Installs0
System Documentation
What problem does it solve?
This Skill prevents FastAPI/REST APIs from silently breaking clients by validating that routes, response schemas, status codes, and OpenAPI output remain consistent with expectations.
Core Features & Use Cases
- Pydantic response schema validation: Enforces exact response shapes (including forbidding extra fields) to detect schema drift and unintended field changes.
- OpenAPI snapshot drift detection: Detects unintended additions/removals and method changes by comparing current
/openapi.jsonagainst a committed snapshot. - Contract-style happy/error path coverage: Standardizes verification of correct status codes for auth, missing resources, and invalid credentials, beyond simple 200 OK smoke checks.
- Route existence checks to stop “case 20” regressions: Fails fast when expected method/path routes are not registered after refactors or integration changes.
Quick Start
Copy the template tests into your project, update APP_IMPORT/EXPECTED_ROUTES/ResponseSchema to match your API, then run your contract test suite with pytest.
Dependency Matrix
Required Modules
None requiredComponents
assets
💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: api-contract-testing-pattern Download link: https://github.com/saintgo7/claude-skills/archive/main.zip#api-contract-testing-pattern Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.