SpecDiff
Stop breaking production. SpecDiff delivers intelligent API contract and schema diffing. Built for modern CI/CD, it detects breaking changes, automates compliance, and slashes code review times across OpenAPI and GraphQL specs. Boost developer velocity, protect uptime, and scale your infrastructure with absolute confidence. Elevate your API lifecycle—deploy seamlessly with SpecDiff today.
Read the technical deep-diveCatching Breaking Schema Changes Before Production with SpecDiff#!/usr/bin/env python3
"""
SpecDiff - Intelligent API Contract & Schema Diffing Engine
Detects breaking API changes, schema drifts, and compliance violations across
OpenAPI and GraphQL specifications to automate CI/CD pipeline safety.
Features:
- Semantic breaking change detection for OpenAPI and GraphQL specs
- Automated API contract compliance and drift analysis
- CI/CD release gate integration with actionable status reports
- Granular severity classification (INFO, BREAKING, DEPRECATED)
- Zero-dependency, lightweight engine built for fast execution
Usage:
$ specdiff compare openapi_v1.json openapi_v2.json --strict
$ python -m specdiff.main --base spec_a.json --head spec_b.json
"""
import json
import sys
from dataclasses import dataclass, field
from enum import Enum, auto
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple, Union
class ChangeSeverity(Enum):
"""Classifies the impact level of a schema change."""
INFO = auto()
NON_BREAKING = auto()
DEPRECATED = auto()
BREAKING = auto()
@dataclass(frozen=True)
class DiffImpact:
"""Represents a single detected delta between two specifications."""
path: str
severity: ChangeSeverity
message: str
rule_id: str
old_value: Optional[Any] = None
new_value: Optional[Any] = None
class SpecDiffer:
"""Core engine for parsing and comparing API specification documents."""
def __init__(self, strict_mode: bool = False) -> None:
self.strict_mode: bool = strict_mode
self._changes: List[DiffImpact] = []
# ... the full file ships with your downloadQuick Start
This tool runs on pure Python 3.8+ using only the Standard Library. No external dependencies or pip install required.
1 — Direct Execution & Agentic Integration
Run it as a standalone utility or call it directly from your AI agents and scripts:
python main.py2 — Import in Your Code / Project
Drop the single file into your project directory and import it natively:
from main import AssetClassHow agents & programs use it: Since it relies purely on the Python Standard Library, your LLM agents (LangChain, AutoGen, or custom runtimes) can execute it as an isolated subprocess or import it directly — no dependency conflicts, no virtual environments.