🛡️ API Contract GuardianCatch breaking API changes before they reach consumers.A VS Code extension that compares API contracts across Git revisions, detects potentially breaking changes, and reports them directly in the VS Code Problems panel.
📖 OverviewAPI contracts can change frequently during development. An endpoint may be removed, a response field may disappear, or a field's type may change — all of which can potentially break existing consumers. API Contract Guardian helps developers detect these changes before they reach downstream consumers. The extension compares API contracts between Git revisions and reports potentially breaking changes directly inside the VS Code Problems panel. Guardian can detect:
Instead of discovering API compatibility problems at runtime, developers can identify them during development. ✨ Features🔌 API Endpoint DetectionGuardian analyzes JavaScript and TypeScript API source files and identifies API routes such as:
If an endpoint existed in the previous Git revision but has been removed, Guardian reports:
📦 Response Contract DetectionGuardian extracts response fields from API responses. For example, a previous response:
becoming:
produces:
🔄 Response Field Type ChangesGuardian detects changes to response field types. For example:
changing to:
is reported as a potentially breaking response-contract change. 👥 Consumer Impact AnalysisGuardian can identify statically detectable JavaScript and TypeScript consumers that access changed response fields. For example:
If
Consumer analysis is intentionally conservative. Dynamic URLs, unsupported HTTP clients, and complex data-flow patterns may not be detected. 🌳 Git-Aware ComparisonGuardian understands changes between Git revisions, including:
This allows API contracts to be compared even when API source files are added or removed between revisions. 🐛 VS Code Problems IntegrationDetected breaking changes are reported using VS Code diagnostics. This allows developers to see API compatibility issues directly inside the VS Code Problems panel. 🔍 What It Detects
🔄 How It Works
The core comparison engine is kept separate from the VS Code-specific layer. 🏗 Architecture
🧠 Tech Stack
🌐 Language SupportAPI DetectionGuardian currently supports:
Consumer AnalysisGuardian currently supports:
The parser architecture is language-independent, allowing additional languages to be added later. 🚀 Usage
⚙️ DevelopmentClone the Repository
Install Dependencies
Type Checking
Linting
Run Tests
Compile the Extension
🧪 TestingThe project includes unit, integration, and end-to-end tests covering:
Unit TestsTests individual components such as:
Integration TestsTests interactions between:
End-to-End TestsTests the complete extension workflow including:
🛡️ Design PrinciplesConservative AnalysisGuardian does not assume that every detected consumer will definitely break. Consumer warnings represent potential impact rather than guaranteed runtime failures. Git-AwareAPI contracts are compared using actual Git revisions.
Separation of ConcernsThe contract analysis engine is separated from the VS Code layer.
This makes the core functionality easier to test and maintain. ⚠️ LimitationsAPI Contract Guardian focuses on statically detectable API contracts. It does not attempt to fully understand:
For example:
may not be statically associated with a specific API endpoint. Therefore, consumer warnings should be treated as potential impact signals, not proof of a runtime failure. 🤝 ContributingContributions, suggestions, bug reports, and feature requests are welcome. If you would like to contribute:
👩💻 AuthorKomal Singh Software Developer • Backend Developer • Open Source Contributor 📄 LicenseThis project is licensed under the MIT License. See the ⭐ If you find API Contract Guardian useful, consider starring the repository. |