api-contract-enforcement

Validates REST API implementations against OpenAPI 3.x specifications for FastAPI and Flask backends.

Updated Feb 8, 2026
One-click install
npx skills add https://github.com/ramshan00/hackaton --skill api-contract-enforcement-ramshan00
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-contract-enforcement
Source: https://github.com/ramshan00/hackaton/tree/main/Hackathon2-phase2/.claude/skills/api-contract-enforcement
Command: npx skills add https://github.com/ramshan00/hackaton --skill api-contract-enforcement-ramshan00

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pyyaml, and includes scripts (resource) and references (resource) components.

What problem does it solve? API implementations often drift from their OpenAPI specifications, causing integration failures, undocumented endpoints, and mismatched request or response payloads that break client applications in production. ## Core Features & Use Cases - Route and Method Validation: Verifies every path and HTTP method in the OpenAPI spec exists in the implementation, including path parameter name matching. - Payload Validation: Compares request body schemas, required fields, field types, and response status codes between spec and implementation. - CI/CD Integration: Returns exit code 0 on success and 1 on violations, with a strict mode that also fails on warnings, making it suitable as a pre-deployment contract gate. - Use Case: Before merging a pull request that adds new FastAPI endpoints, run the validator against your openapi.yaml to catch a missing required field like 'email' in the request model before it reaches production. ## Quick Start Ask the AI to validate your API implementation by running the contract validation script against your OpenAPI spec file and backend module, then fix any reported violations.

Frequently Asked Questions about api-contract-enforcement

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

FAQPage Schema
How do I validate a FastAPI app against an OpenAPI spec?

Run the validation script with your OpenAPI YAML or JSON file and the Python module containing your FastAPI app as arguments. The script extracts routes from the app automatically and compares them against every path, method, and schema in the spec.

How to check API contract compliance in CI/CD pipelines?

Execute the validation script as a pipeline step before deployment. It exits with code 0 when the implementation matches the spec and code 1 on violations, so the pipeline fails automatically on contract mismatches.

Does OpenAPI validation work with Flask applications?

Yes, the validator supports Flask by inspecting the app's URL map for routes and methods. However, Flask lacks automatic schema extraction, so request body and response validation is limited compared to FastAPI's Pydantic-based introspection.

Why does validation report a path parameter mismatch?

This occurs when the parameter name in the spec differs from the implementation, such as '{id}' in the spec versus '{user_id}' in the route. Rename the parameter in either the spec or the route handler so both match exactly.

What is the difference between standard and strict validation mode?

Standard mode reports critical violations like missing endpoints and mismatched path parameters. Strict mode additionally fails on warnings such as type mismatches, extra response fields, and missing validation constraints, suiting production deployment gates.