How do you detect API contract drift before it breaks consumers? #205627
Replies: 5 comments
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
|
English Version (Gunakan ini untuk membalas di GitHub) A robust workflow generally combines three layers of enforcement: Design-Time Linting & Structural Diffing (CI): Consumer-Driven Contract Testing: Runtime Schema Validation in Test Suites: Plaintext |
|
Catching this manually or post deploy is a losing battle. The only reliable way is enforcing it automatically in CI. A few things that i thnk is the best in practice:
If you don't already have contract testing set up, starting with a basic |
|
Drift detection only earns its keep if it runs at PR time, not after deploy. The pragmatic stack I use: 1. Schema diffing on every PR (enforced, not optional). Keep one OpenAPI spec as the source of truth; a CI job diffs the PR's spec against - uses: actions/checkout@v4
with: { fetch-depth: 0 }
- run: |
URL=$(curl -s https://api.github.com/repos/Tufin/oasdiff/releases/latest | jq -r '.assets[].browser_download_url | select(test("linux_amd64"))')
curl -sL "$URL" | tar xz
./oasdiff breaking https://raw.githubusercontent.com/${{ github.repository }}/main/openapi.yaml openapi.yaml
2. Contract tests, not just schema tests. 3. Generated-client compile check. If you ship SDKs: regenerate the client from the spec inside your own CI and keep a consumer compile job. A type-level breakout ("field gone") stops the merge with a precise error. 4. Runtime drift monitor as backstop. Production changes happen outside the spec (a manual view tweak, a gateway rewrite). A scheduled job runs 5. Governance lint. GitHub-specific tip since you mention CI/CD pipelines: GitHub's own API schema lives in the If this is the playbook you were looking for, marking it as accepted helps others land on it. 🚀 |
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Bug
💬 Feature/Topic Area
API
Body
I've been thinking about API contract drift lately.
An API can remain technically functional while slowly diverging from the contract that consumers actually depend on.
For example:
The OpenAPI definition says one thing, but the endpoint behaves differently
A response field changes unexpectedly
An HTTP status code changes
Documentation isn't updated after an API change
A new endpoint doesn't follow existing API standards
A seemingly small change breaks an SDK or automation workflow
This seems especially risky when APIs are consumed by CI/CD pipelines, generated clients, or other services.
I've been testing Apidog for this kind of workflow because it combines API design, testing, documentation, and governance rather than treating them as completely separate processes.
The governance features I found particularly useful are:
Endpoint Compliance Check
API Documentation Completeness Check
Secret Scanner
Audit Logs
RBAC
The workflow I'm experimenting with is:
API change → contract validation → governance checks → API testing → CI/CD
The goal isn't to prevent developers from changing APIs. It's to make potentially breaking changes visible before consumers discover them in production.
How are you handling API contract drift today?
Do you rely on OpenAPI linting, contract testing, CI checks, or a dedicated API governance tool?
I'd especially like to hear how teams detect changes that are technically valid but still break real API consumers.
All reactions