Why Drift Detection Matters
API documentation is only useful if it accurately reflects what is deployed. Often, developers modify controller parameters or validation rules without updating the committed OpenAPI specification file, leading to broken client SDKs and outdated documentation. Geni includes a dedicated drift detection command:How geni:check Works
When geni:check runs:
- It regenerates the OpenAPI document in-memory by analyzing the current codebase.
- It reads the committed specification file at
--path. - It normalizes and canonicalizes both documents by recursively sorting object keys while preserving semantically significant array orders.
- It compares the two specifications:
- If they are identical, it outputs
"OpenAPI specification at openapi.json is up to date."and exits with code0. - If they differ, it prints a human-readable list of added, removed, or changed paths, methods, parameters, and schemas, and exits with code
1.
- If they are identical, it outputs
Adding to GitHub Actions
Add a drift check step to your GitHub Actions workflow:.github/workflows/ci.yml
php artisan geni:export --path=openapi.json, the CI step fails and blocks the PR from merging.
Diagnostic Relativization
To ensure that specifications generated on different developer machines (or in CI containers) produce identical output without false drift, Geni automatically relativizes all absolute file paths before storing them inx-geni-unresolved extensions.