Contract Testing

Overview

Contract Testing automatically validates captured HTTP traffic against OpenAPI (Swagger) specifications. Load an API spec and all requests/responses passing through the proxy are checked against it in real-time, reporting any violations.

Catch discrepancies between API specs and actual implementations early to prevent contract violations between frontend and backend.


How It Works

flowchart TD
    A[Load OpenAPI Spec] --> B[Parse and Activate Spec]
    C[Capture HTTP Traffic] --> D{Active Spec Exists?}
    D -->|No| E[Skip Validation]
    D -->|Yes| F[Path Matching]
    F --> G{Matching Path Found?}
    G -->|No| H[PathNotFound Violation]
    G -->|Yes| I[Schema Validation]
    I --> J[Record Validation Result]

    style H fill:#ffebee
    style J fill:#e8f5e9
  1. Load an OpenAPI spec file (JSON or YAML)
  2. Perform path matching on traffic passing through the proxy
  3. Compare actual requests/responses against the matched path's schema
  4. Report violations

Spec Management

FeatureDescription
LoadLoad an OpenAPI spec file (JSON/YAML supported)
UnloadRemove a loaded spec
Enable/DisableToggle validation for individual specs
ListView loaded specs

Multiple OpenAPI specs can be loaded simultaneously, each individually toggleable.


Validation Results

Each result includes:

FieldDescription
Request IDValidated transaction identifier
Spec IDMatched OpenAPI spec
ViolationsList of violations found
Matched PathMatched path pattern from spec
Matched OperationMatched HTTP method

Use Cases

API Development Validation

Load your API spec during backend development to get immediate feedback when actual responses differ from the spec. Automatically detect field type mismatches, missing required fields, and more.

Frontend-Backend Integration Testing

Validate that actual communication follows the API contract agreed upon by frontend and backend teams.

API Migration

Load the existing spec during API version upgrades to verify that new version responses don't break existing contracts.


Usage

Desktop

  1. Select Contract Testing from the sidebar
  2. Load an OpenAPI spec file
  3. Validation runs automatically during traffic capture
  4. Review violations

MCP

"Load the OpenAPI spec"
"Show me the Contract Testing validation results"