Repository navigation
feat(#416): real OpenAPI 3.0 spec at /api/openapi - #456
Open
woahwhattheheck wants to merge 5 commits into
Open
woahwhattheheck wants to merge 5 commits into
woahwhattheheck wants to merge 5 commits into
Conversation
Wire routeDoc exports on every app/api route (matching the ingest-historical convention), aggregate them into a valid OpenAPI 3.0 document at GET /api/openapi, fix the mangled PUBLIC_ROUTES entry, and add drift + schema-validator tests so the docs page stops failing on load.
Model the middleware API key and metrics bearer token as one AND security requirement when METRICS_TOKEN is configured. Leave API-key-only security when unset, remove the ignored Authorization header parameter, and avoid putting any token value in the public specification. The installed Swagger request builder reproduced the missing Authorization header before this change; its generated request now reaches the existing metrics handler successfully. Metrics/OpenAPI checks: 18 passed. Changed files pass TypeScript and Prettier. Required full tests: 677 passed, 96 failed, 18 skipped; all 103 failure reports (including collection errors) match unchanged parent 0831c76. Whole-project TypeScript/lint diagnostics also match that parent. Build still stops on the four unchanged parser errors in clickhouse-ingest, historical-ingester, dag/engine, and jobs/queue. No full-build/CI-green claim. Refs Open-audit-foundation#416
Reuse the nine production postimages from 31972c3, retaining the OpenAPI and metrics changes on this branch. All original blobs matched that repair's parent. The composed application compiles with Turbopack and passes the full TypeScript check (npm run lint, Node heap 512 MiB). The complete Next build remains unverified: its TypeScript worker was killed under shared memory pressure, and the subsequent bounded build hit ENOSPC. No full-suite or hosted-CI success is asserted. Source repair: 31972c3 Operation: OA455-456-BUILD-REPAIR-REUSE-20261003-01
Align the JSON response metadata with the unchanged streamed array and its nine row fields. Extend the existing export regression to check populated and empty responses against the generated document, and reject a serialized JSON string as the response value. Prettier passes using the repository configuration. Maintained tests, type checking and lint are not rerun in this continuation because the exact retained dependency donor is unavailable; their remaining acceptance requirements are preserved.
Allow null alongside the documented live/historical Event source values. Exercise actual list/search JSON against the served specification, retaining rejection of unknown strings and numeric sources. Focused execution: original enum reproduced 2 failures; repaired selection passed 21 tests, including existing OpenAPI validation/drift and JSON export cases. Preserve the source-bound results and formatting-only limitations in docs/validation/openapi-event-source-20261004.md. Runtime handlers, dependencies and prior fixes are unchanged.
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 #416.
/docspointed Swagger UI at/api/openapi, but that route did not exist, so the docs page failed for every visitor. This PR:routeDocconvention across everyapp/api/**/route.tsGET /api/openapithat aggregates those docs into a valid OpenAPI 3.0 document with security schemes, shared component schemas, and request/response shapesmiddleware.tsPUBLIC_ROUTES: replaces the mangled/api/ingest-historical/openapientry with/api/openapisource: nullresponse compatibility while continuing to documentliveandhistoricalas the non-null source valuesAcceptance
/api/openapireturns a valid OpenAPI 3.0 document/docscan fetch/api/openapias a public routeapp/api/exportsrouteDocsource: nullpluslive/historical, while rejecting unknown strings and numeric source valuesFocused validation
The current-head validation receipt is documented in
docs/validation/openapi-event-source-20261004.md.A source-bound selection passed 21 tests, 0 failures, 0 pending:
npm exec -- vitest run \ lib/openapi/__tests__/event-responses.test.ts \ lib/openapi/__tests__/openapi-spec.test.ts \ app/api/v1/events/export/route.test.ts \ --maxWorkers=1 --reporter=json --outputFile=after.jsonThat selection includes the new list/search compatibility cases, maintained OpenAPI validator/drift cases, and export schema regressions. It calls the actual handlers and obtains schemas from the actual public OpenAPI handler; database/authentication collaborators are controlled.
Formatting follow-through ran Prettier write/check successfully on the final files. The hosted workflow's overall result was not green because a later byte-for-byte emitted-JavaScript comparator treated a whitespace-only line-wrap change as significant. Independent TypeScript parsing found zero diagnostics and identical syntax trees excluding positions/trivia. No functional rerun is claimed for that whitespace-only formatting edit.
Evidence boundary
No full-suite, full application typecheck/build, live database, deployed Swagger browser, authentication, upstream CI approval, or maintainer-acceptance result is asserted by this focused continuation. The original PR, branch, and contributor are preserved.
Notes
routeDocobjects only; drift coverage keeps the registry honest