docs(api): document v1 conventions and add contract drift tests (#829) - #839
Conversation
Expand openapi.json with the canonical files/by-path, files/file-url, and files/visibility routes, add a static contract test that compares the files/usage/galleries verticals registered on the Hono app against openapi.json and docs/api.md, and extend docs/api.md with a collection envelope table and error type/code/status semantics (§1 residue + §6).
|
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (2)
🚫 Excluded labels (none allowed) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
Issue #829's §1 checklist had two items left unfinished after PR #830: the
OpenAPI document didn't cover several registered canonical file routes, and
nothing caught drift between the three descriptions of the public API
(registered routes,
openapi.json,docs/api.md). §6 asked to freeze thev1 collection-envelope and error conventions in prose.
Changes
§1 residue
apps/web/public/.well-known/openapi.json: added the three canonical fileroutes that were registered but undocumented —
GET .../files/by-path,GET .../files/file-url, andPATCH .../files/visibility.apps/api/src/openapi-contract.test.ts: a new static test that loads theHono
app'sapp.routes,openapi.json, anddocs/api.md, and assertsthey agree on the files/usage/galleries verticals (plus
/public/galleries/:id).It flags a route missing from either doc and a documented path that no
longer exists on the app. I verified it actually catches drift by
temporarily renaming a path in
openapi.jsonand watching it fail.§6 — freeze v1 conventions
docs/api.md"Pagination" section: added a "Collection envelope shapes"table listing the exact field set for every list endpoint
(
{ files, prefixes, cursor },{ items, truncated, cursor }, etc.),extending the existing section from PR feat(api): cursor-paginate file search (#829) #838 rather than duplicating it.
docs/api.md"Errors" section: clarified thattypeis the broadcategory and
codeis the stable branch key, and documented that anAppErrorcan override its default HTTP status but that override nevertravels on the wire (verified against
packages/errors/src/base.tsandtypes.ts— no route uses the override today).Scope note
The contract test covers the files/usage/galleries verticals — the ones
issue #829 named and the ones
docs/api.md's "Canonical routes" tabledocuments. The canonical
github/members/storage/billingverticals(issue #613 phases 2–3) are session-only account management with their own
docs; folding them into this guard is a separate, larger piece of work and
is called out as out of scope in the test's docblock rather than silently
expanded.
Nothing renamed or removed — additive only. Legacy
/v1/:workspace/...stays documented as a compatibility family, not path by path.
Testing
pnpm test(root): 5140 tests pass.pnpm --filter @uploads/api typecheck: clean.openapi.jsonto confirm the new test fails asexpected, then restored it.
Refs #829 §1, §6.