feat: Enforce OpenAPI artifact drift checks for every route (Closes #… - #946
Merged
greatest0fallt1me merged 1 commit intoAug 29, 2026
Conversation
|
@Killerjunior Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #938
This PR implements comprehensive and deterministic OpenAPI artifact drift checks across every route in
predictify-backend. It expands the OpenAPI registry definitions to achieve 100% route parity with Express route handlers, updatesscripts/check-openapi.tsto perform multi-stage verification (structure, route coverage, artifact drift with line ending normalization, and route contract invariants), updatesopenapi.yaml, and introduces exhaustive automated tests intests/openapi.drift.test.ts.Key Changes
OpenAPI Route Registry Parity (
src/openapi/registry.ts):bearerAuth) for protected endpoints and documented standard auth failure codes (401/403).400validation error envelopes for paginated endpoints (cursor/limit).data,nextCursor) and documented OpenAPI components.Automated Drift & Invariant Checks (
scripts/check-openapi.ts):validateStructure: Validates OpenAPI 3.1.0 document integrity, info metadata, and paths object.validateRouteCoverage: Enforces bidirectional 1:1 route parity betweenEXPECTED_ROUTESand the generated specification, catching missing or undocumented routes.validateArtifactDrift: Verifies byte-for-byte reproducibility ofopenapi.yamlwith CRLF/LF line-ending normalization.validateRouteInvariants: Enforces contract rules across all operations:operationIdacross the entire specification.tagsandsummary/description.2xx/304success responses.bearerAuthdocument401or403error responses.{param}and declaredin: "path"parameters.400validation errors.Metrics & Route Fixes (
src/metrics/registry.ts,src/routes/predictions.ts):predictionsListTotal,predictionExplainTotal,predictionsRequestDuration).GET /api/predictions/:id/explainmoved beforerequireAuthguard with UUID route parameter validation and ETag caching.Automated Drift Test Suite (
tests/openapi.drift.test.ts):operationId, missing tags, missing auth errors, missing path params, and paginated validation).Acceptance Criteria Mapping
EXPECTED_ROUTESand OpenAPI registry ensures no missing or extra routes.bearerAuth->401/403, path parameters parity, and paginated400responses across all operations.npm run openapi:generateandnpm run openapi:checkrun deterministically in CI with zero drift.tests/openapi.drift.test.tsandtests/openapi*.test.tscover success, rejection, missing route, and stale artifact scenarios.Validation Commands