Api Contract Tester v2

    2

    Auto-generate API contract tests from OpenAPI/GraphQL. Detect drift, breaking changes. Mock server + multi-language client gen.

    Free

    5 usesSecurity scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    api-contract-tester-v2

    Example session with this skill installed

    Verify our local openapi.yaml against the production API at https://api.acme.com and check for any breaking changes compared to openapi-v1.yaml.

    • Read your context and instructions
    • Compiled the api-contract-tester-v2

    Found 2 contract violations: Response missing field 'created_at' and type mismatch on 'id' (expected string, got number). 1 breaking change: 'User.email' is now required. Verdict: BLOCK.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    API Contract Tester

    Your docs say the API returns {id, name, email}. The code returns {id, name, email_hash, is_verified}. The client breaks in prod. This skill catches that mismatch before merge — automatically, on every PR.

    What it does

    • Generates contract tests from OpenAPI 3.x or GraphQL SDL
    • Validates live or recorded responses against the spec
    • Detects drift — fields added, removed, type-changed
    • Catches breaking changes — required field added, type narrowed, enum removed
    • Generates clients — TypeScript, Python, Go, Java from spec
    • Mock server — stand up a fake API from spec for local dev
    • CI gate — fail PR if contract violated

    When to use it

    • Your API has an OpenAPI/GraphQL spec but you don't know if the code matches
    • You ship breaking changes by accident
    • You want to generate clients in multiple languages from one source
    • You need a mock API for frontend dev
    • You're adding a new endpoint and want CI to enforce the spec
    • You're integrating a third-party API and want to know if it changed

    Why it's better than ad-hoc prompting

    Most "test my API" prompts give generic advice. This skill is different:

    • Spec-driven — every test comes from the contract, not vibes
    • Drift-aware — distinguishes breaking vs non-breaking changes
    • Multi-protocol — REST + GraphQL in one tool
    • CI-friendly — exits non-zero on contract violation
    • Mock included — no need for a separate Prism/Mockingjay setup

    Architecture

    ┌─────────────────────────────────────────────────────────┐
    │               Agent (Claude/Cursor)                     │
    │  - Points at OpenAPI/GraphQL spec + code                │
    │  - Runs contract tests                                  │
    │  - Reports drift + breaking changes                     │
    └───────────────┬─────────────────────────────────────────┘
                    │
                    ▼
    ┌─────────────────────────────────────────────────────────┐
    │          skills/api-contract-tester/                    │
    │  scripts/                                                │
    │    ├── test_rest.py          # OpenAPI contract tests    │
    │    ├── test_graphql.py       # GraphQL contract tests    │
    │    ├── detect_drift.py       # Compare code vs spec      │
    │    ├── check_breaking.py     # Semver-aware change detect│
    │    ├── generate_client.py    # TS/Py/Go/Java clients     │
    │    └── mock_server.py        # Spec → mock server        │
    │  references/                                             │
    │    ├── breaking-changes.md                                │
    │    ├── openapi-tips.md                                    │
    │    └── graphql-tips.md                                    │
    │  examples/                                               │
    │    ├── petstore.yaml                                     │
    │    └── github.graphql                                    │
    └─────────────────────────────────────────────────────────┘
    

    Quick start

    # 1. Install
    pip install openapi-spec-validator prance httpx graphql-core
    
    # 2. Run contract tests against live API
    python scripts/test_rest.py --spec openapi.yaml --base-url https://api.example.com
    
    # 3. Detect drift between code and spec
    python scripts/detect_drift.py --spec openapi.yaml --code ./src/api/
    
    # 4. Check a PR for breaking changes
    python scripts/check_breaking.py --old openapi-v1.yaml --new openapi-v2.yaml
    
    # 5. Generate a TypeScript client
    python scripts/generate_client.py --spec openapi.yaml --lang typescript --out clients/
    
    # 6. Stand up a mock server
    python scripts/mock_server.py --spec openapi.yaml --port 4010
    # → mock API at http://localhost:4010
    

    Sample output

    ## API Contract Test Report
    
    **Spec**: openapi.yaml (v2.3.1, 47 endpoints)
    **Base URL**: https://staging.api.example.com
    **Endpoints tested**: 47/47 ✅
    **Total assertions**: 312
    **Pass**: 305 | **Fail**: 7
    
    ### Failures
    
    #### GET /users/{id} (3 failures)
    - ❌ **Response missing field** — spec requires `created_at`, response lacks it
    - ❌ **Response extra field** — `internal_id` in response, not in spec (potential leak)
    - ❌ **Type mismatch** — spec says `id: string`, response has `id: number`
    
    #### POST /users (4 failures)
    - ❌ **Required field missing** — request must include `email`, test sent without
    - ❌ **Status code wrong** — spec says 201, got 200
    - ❌ **Response missing field** — spec returns `verification_token`, response lacks it
    - ❌ **Header missing** — spec requires `X-RateLimit-Remaining` header
    
    ### Drift between code and spec
    - `internal_id` field in User schema (src/models/user.py:23) but not in spec
    - `is_verified` field in spec but not in code (src/api/users.py:89)
    
    ### Breaking changes vs v2.2.0
    - 🛑 `User.email` changed from optional to required
    - 🛑 `User.id` type changed from string to integer
    - ⚠️ `User.role` enum lost the `guest` value
    
    ### Verdict: 🛑 BLOCK — 7 contract violations + 2 breaking changes
    

    Breaking change detection (semver-aware)

    ChangeSeverityAction
    New optional fieldNon-breaking✅ OK
    New required fieldBreaking🛑 MAJOR bump
    Field type narrowed (any → string)Non-breaking✅ OK
    Field type broadened (string → any)Breaking🛑 MAJOR bump
    Enum value addedBreaking🛑 MAJOR bump
    Enum value removedBreaking🛑 MAJOR bump
    New endpointNon-breaking✅ OK (MINOR bump)
    Endpoint removedBreaking🛑 MAJOR bump
    New optional parameterNon-breaking✅ OK
    Parameter made requiredBreaking🛑 MAJOR bump
    Response status addedNon-breaking✅ OK
    Response status removedBreaking🛑 MAJOR bump

    Pricing

    Single-purchase, lifetime access. $7.50.

    Includes:

    • 6 Python scripts (REST, GraphQL, drift, breaking, client, mock)
    • 3 reference docs (breaking changes, OpenAPI tips, GraphQL tips)
    • 2 example specs (Petstore, GitHub GraphQL)
    • Future updates for the same major version

    Example usage

    "Here's our OpenAPI spec and the API base URL. Tell me if the code matches, and flag any breaking changes since v2.2."

    The skill will:

    1. Fetch the spec
    2. Run 300+ contract assertions against the live API
    3. Diff code vs spec for drift
    4. Compare current spec to old version
    5. Output contract-report.md with deployable/hold decision

    Compatibility

    Works with any agent that supports the SKILL.md standard and can execute Python: Claude Code, OpenClaw, Codex CLI, Cursor, Gemini CLI, Cline, Windsurf, Aider. Supports OpenAPI 3.0/3.1, GraphQL SDL, JSON Schema. Tested on Linux, macOS, Windows.

    Tags

    api, testing, openapi, graphql, rest, contract-testing, qa, ci-cd, backend

    • Requires Python environment for script execution.
    • Complex nested GraphQL fragments might require manual schema tuning.
    • Does not automatically fix code, only detects drift and breaking changes.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    5 uses

    Times used to date

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 4 months ago

    • Free with an Agensi account

    Permissions

    Terminal / Shell
    Network Access
    Listed4 months ago

    What's inside

    Frequently Asked Questions

    This skill performs spec-driven validation to ensure your code matches your OpenAPI or GraphQL documentation. It catches 'drift'—like missing fields, type mismatches, or unexpected extra data—and identifies breaking changes that would crash your frontend or mobile clients.

    It works with any AI agent that can execute Python and access a file system, including Claude Code, Cursor, Aider, Windsurf, and Cline. It leverages standard libraries to provide consistent, 'spec-first' logic that generic prompts can't replicate.

    The package includes six high-performance Python scripts for REST/GraphQL testing, drift detection, and breaking change analysis, plus professional reference guides and example schemas. You get everything needed to integrate contract testing into your PR workflow or local dev environment.

    The skill supports OpenAPI 3.0/3.1 and GraphQL SDL. For legacy systems, it can also validate against standard JSON Schema definitions, making it versatile for most modern web architectures.

    Installation is a simple one-line pip command for dependencies. Once installed, the agent uses the provided scripts to automatically analyze your specs and codebases, requiring zero manual configuration for most standard API structures.

    Your purchase covers lifetime access including all future updates within the current major version. You will receive notification through the marketplace whenever the scripts are optimized for new OpenAPI standards or agent capabilities.

    New in Testing & Debugging

    Free