Skip to main content

Detect breaking changes in your OpenAPI specs before they hit production

Project description

🇪🇸 Español

Contractor

Detect breaking changes in your OpenAPI specs before they hit production.
One command. No config. Zero false positives.


The Problem

You renamed a field in your API response. Three services depend on it. You find out at 3 AM from a PagerDuty alert.

Contractor catches this in CI/CD, before merge. It tells you exactly what changed, where, and who needs to know.


Quick Start

pip install contractor

# Compare two OpenAPI specs:
contractor diff --base openapi-main.yaml --candidate openapi-feature.yaml

Requirements: Python 3.10+ and oasdiff v1.18+ (brew install oasdiff)


What It Detects

Category Example
🚫 Endpoints removed DELETE /users/{id} disappears
⚠️ Required params added ?filter becomes mandatory
🔀 Type changed amount: stringamount: number
📋 Required fields added New field in request body required[]
🔒 Enum / Constraint changes Valid values removed, limits tightened
🧩 Schema composition changed allOf / anyOf restructured
🛡️ Security scheme changes OAuth scopes removed
📅 Deprecation violations API removed before sunset date
…plus 450+ rules via oasdiff engine

Usage

contractor diff --base main.yaml --candidate feature.yaml
Flag Description Default
--base Path to the baseline OpenAPI spec required
--candidate Path to the candidate OpenAPI spec required
--format Output: console, json, markdown console
--output Write report to file none
--engine Detection engine: oasdiff or legacy oasdiff

Exit codes: 0 = safe to merge • 1 = breaking detected • 2 = error


Build del ejecutable

Para generar un ejecutable de Windows independiente del CLI:

cd cli
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements-dev.txt
pyinstaller contractor.spec

Esto generará el ejecutable en cli/dist/contractor.exe.

También puedes usar el script de build incluido:

cd cli
build-exe.bat

Nota: el motor por defecto es oasdiff, que debe estar disponible en PATH. Si no deseas depender de oasdiff, ejecuta el binario con --engine legacy:

</code></pre>
</blockquote>
<p>dist\contractor.exe diff --base main.yaml --candidate feature.yaml --engine legacy</p>
<blockquote>
<pre><code>

Output Formats

Console (default)

Colored table via Rich — Type, Location, Description.

JSON

{
  "breaking": true,
  "count": 1,
  "changes": [
    {
      "kind": "endpoint_removed",
      "path": "/users/{id}",
      "method": "DELETE",
      "location": "base.yaml:24:5",
      "description": "api removed without deprecation"
    }
  ]
}

Markdown

Markdown table for PR comments. Generate with --format markdown --output report.md.


CI/CD Integration

GitHub Actions

- name: Check API contract
  run: contractor diff --base main/openapi.yaml --candidate pr/openapi.yaml

See full template at templates/github-action.yml.

GitLab CI

api-contract-check:
  script:
    - pip install contractor
    - contractor diff --base openapi/main.yaml --candidate openapi/feature.yaml --output report.md
  artifacts:
    when: on_failure
    paths: [report.md]

Framework Support

Python · JavaScript · Java · Go · PHP · Ruby · Rust · C# · Kotlin · Elixir · Scala

Works with FastAPI, Express, Spring Boot, Gin, Laravel, Rails, Actix-Web, ASP.NET Core, Ktor, Phoenix, Play — and 25+ frameworks.


How It Works

contractor
  └─ oasdiff (450+ detection rules)
       └─ adapter → internal model
            └─ formatters (console, json, markdown)

Detection powered by oasdiff. We focus on team orchestration — alerts, PR comments, audit history, zero-config setup.


Test Suite

236 tests — all passing. Covers adapters, CLI, formatters, legacy engine, parser, models, and end-to-end integration.


Contractor is free and open-source (MIT). Enterprise features (team alerts, audit dashboard, SSO) are available.


Contributing

MIT License. Contributions welcome.

See cli/README.md for development setup and docs/detection-engine.md for architecture details.


Tests License Python

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

contractor_cli-0.1.0.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

contractor_cli-0.1.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file contractor_cli-0.1.0.tar.gz.

File metadata

  • Download URL: contractor_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for contractor_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9c97ac6c500f530d3670edb84027781bfb3811fff6236b94023a52f2272f6d22
MD5 8c7b786e08f487d77228cae24d37602b
BLAKE2b-256 06384e807f28403955befb394904cbb70b852e6c43e400c69030b8cdca74dc40

See more details on using hashes here.

File details

Details for the file contractor_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: contractor_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for contractor_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e48b24b4b46c4b03c91b55d77e1068fcccbb9882dd7d72d8c61712476e965c6
MD5 f71a87b6f6c29b657e5f233d33df3540
BLAKE2b-256 ad1f15783f676bbb93966a3b196d99d162d21327bdee63a75b6bf591701d9f31

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page