Block breaking OpenAPI changes and probe routes before traffic shifts
Validate OpenAPI changes with `gregale api spec preview`, `diff` and hash-pinned `apply`—exiting `2` on breaks and `3` on `UNKNOWN` schema changes while blocking promotion—and probe up to ten `x-gregale-hosting-check: true` GET routes on the exact candidate.
Catch breaking OpenAPI response changes and verify key GET routes on the exact release candidate before production traffic moves. Gregale validates schema compatibility with gregale api spec preview, diff, and hash-pinned apply—exiting 2 on confirmed breaks and 3 on UNKNOWN schema changes while blocking promotion—and can probe up to ten read-only endpoints marked x-gregale-hosting-check: true before shifting live traffic.
Why breaking API contracts slip past unit tests
Internal unit and integration suites usually test the new server code against updated mocks. Meanwhile, removing a required field from a JSON response, changing a oneOf or anyOf union branch, or narrowing an enum or format breaks existing mobile clients and partner integrations immediately in production. Most teams either leave contract compatibility to manual PR review or stitch together third-party diff tools like oasdiff or Optic plus custom post-deploy smoke scripts in CI.
Preview, diff, and hash-pinned contract apply
Gregale provides a read-only preview and diff workflow paired with an idempotent, SHA-256-pinned apply step, and serves the published contract at /docs:
gregale api spec preview APP_ID
gregale api spec diff openapi-baseline.yaml openapi.yaml
gregale api spec apply APP_ID --confirm --preview-sha256 SHA256
previewanddiffare strictly read-only.applyrequires the exactpreview-sha256hash returned bypreview, guaranteeing that the contract you reviewed is the contract you publish.
Strict exit codes and the UNKNOWN promotion gate
Gregale refuses to treat ambiguous schema edits as safe by default:
- Exit code
2(confirmed breaking change): Returned for definite client breaks such as removing a response field'srequiredguarantee. - Exit code
3(UNKNOWNcomparison): Returned whengregale api spec diffsees changedoneOforanyOfresponse schemas, or edits to unsupported schema facets such asenum,format, constraints, or composition where client safety cannot be proven automatically.
In production contract previews, ambiguous diffs appear in unknowns, and the contract gate blocks promotion while any unknown remains. Older snapshots that predate schema fingerprinting can report union_baseline_incomplete or schema_baseline_incomplete; a fresh production deployment with the gate temporarily off captures a full baseline for subsequent comparisons.
Exact-candidate pre-promotion route checks
Beyond static schema diffing, you can mark up to ten static, read-only GET operations in your OpenAPI spec so Gregale probes the exact new deployment candidate before switching live traffic:
paths:
/v1/health:
get:
x-gregale-hosting-check: true
responses:
'200':
description: API is ready
Checks follow strict safety and determinism rules:
- Only explicitly marked operations are probed, using an empty
GETwith no redirects, path parameters, or query strings. - Pass criteria:
2xx,3xx,401, or403. Treating401and403as healthy means you can confirm that an auth-protected route is wired and answering on the new candidate without embedding customer credentials in your deploy pipeline. - Fail criteria:
404,429, or5xxfails the candidate before production traffic moves.
Each route result and the imported OpenAPI document's hash are stored in the deployment hosting receipt. Specs without marked operations fall back to Gregale's standard health and connectivity gates.
What it does and does not replace
Pre-promotion route checks prove that each marked route answered cleanly on the exact candidate revision; they do not parse response JSON bodies against schemas at runtime, nor do they substitute for runtime error monitoring. Pair OpenAPI hosting gates with canary deploys with automatic rollback so any runtime regression in real traffic still rolls back automatically.
See OpenAPI hosting, Release safely, and Errors for full usage details.
Questions
- How does Gregale block breaking OpenAPI changes before deployment?
Run
gregale api spec preview,diffand hash-pinnedapply --confirm --preview-sha256. Confirmed breaks such as dropping arequiredresponse field exit with code2, while ambiguousoneOf,anyOf,enum, orformatedits reportUNKNOWNwith exit code3and block promotion.- How do pre-promotion OpenAPI route checks handle authenticated endpoints?
Mark up to ten static, read-only
GEToperations withx-gregale-hosting-check: true. Gregale probes the exact new candidate and treats2xx,3xx,401, and403as passes while failing404,429, and5xx, proving auth-gated routes exist without storing test credentials.- Do OpenAPI checks replace runtime canary rollouts?
No. Route checks confirm candidate reachability and exit
2/3rules catch static schema regressions before traffic shifts, while Gregale canary rollouts monitor real production error rates after promotion.