SpecDiff
Basta causare disservizi in produzione. SpecDiff offre un diffing intelligente di schemi e contratti API. Progettato per la moderna CI/CD, rileva i breaking change, automatizza la compliance e riduce drasticamente i tempi di code review per le specifiche OpenAPI e GraphQL. Aumenta la velocità di sviluppo, proteggi l'uptime e scala la tua infrastruttura in totale sicurezza. Porta il ciclo di vita delle tue API a un livello superiore: effettua il deploy senza intoppi oggi stesso con SpecDiff.
Leggi l'approfondimento tecnicoIndividuare i Breaking Change nelle API prima della Produzione con 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
Questo tool gira con puro Python 3.8+ usando solo la Standard Library. Nessuna dipendenza esterna, nessun pip install.
1 — Esecuzione Diretta e Integrazione Agentica
Lancialo come utility standalone o chiamalo direttamente dai tuoi agenti AI e script:
python main.py2 — Importalo nel Tuo Codice / Progetto
Trascina il singolo file nella cartella del tuo progetto e importalo nativamente:
from main import AssetClassCome lo usano agenti e programmi: Siccome si basa solo sulla Standard Library di Python, i tuoi agenti LLM (LangChain, AutoGen o runtime custom) possono eseguirlo come subprocess isolato o importarlo direttamente — nessun conflitto di dipendenze, nessun virtual environment.