Skip to content

Make the API docs and the discovery document match the server - #25

Open
0bserver07 wants to merge 1 commit into
tobi:mainfrom
0bserver07:fix/api-docs-match-server
Open

Make the API docs and the discovery document match the server#25
0bserver07 wants to merge 1 commit into
tobi:mainfrom
0bserver07:fix/api-docs-match-server

Conversation

@0bserver07

@0bserver07 0bserver07 commented Aug 27, 2026

Copy link
Copy Markdown

The discovery document at /api/v1 advertised GET /{owner}/{repo}/api/commit/{sha}/merge-queue, which has no route, and pointed docs at https://git.example.com/api no matter which host answered. Both are gone: the endpoint line is removed and docs is now derived from the request base like every other URL in the document (AGENTS.md section 5: nothing in crates/ knows a hostname).

The docs disagreed with the code in a few more places I hit while reading the API contract:

  • web/API.md section 5 said every write on the JSON surface needs admin. Creating a repository and starting an op need write (admin.rs:19, ui.rs:1084); deleting a repository and writing policy or settings need admin (admin.rs:48, policy.rs:682, settings.rs:136).
  • The API page in the UI (web/src/pages/ApiPage.tsx) said the same wrong thing about policy, three lines under a row that 527c7d1 had already corrected; it had no row for settings at all, and dropped the /api segment from every repository path.
  • web/API.md, docs/CONTRACT.md and the SDK comment in web/sdk/repos.ts promised an [integrations] settings section; SETTINGS_SECTIONS in walgit-config accepts four sections and a PUT with [integrations] is a 400.
  • The section 6 checklist gave browser_base as /api/v1 instead of /api-browser/v1; the overview shape pointed at an overview.go that does not exist; docs/BUNDLE_URI_DESIGN.md still named /services/install.sh instead of /services/public/install.sh.

Tests: api_v1 now asserts that docs is derived from the discovery base, and a new test pins the write gates (a write token gets 403 on PUT and DELETE of policy and settings, an admin token gets 204 and 200). The walgit-config settings test asserts [integrations] is refused.

Checked with cargo test -p walgit-server --test api_v1, cargo test -p walgit-config and pnpm run build (oxlint, tsc). The clippy step in CI fails on main today for reasons unrelated to this change (see #24); clippy reports nothing in the lines touched here.

The /api/v1 discovery document listed GET /{owner}/{repo}/api/commit/{sha}/merge-queue,
which has no route, and pointed docs at https://git.example.com/api on every host. The
endpoint line is gone and docs is now derived from the request base like the other URLs
in the document (AGENTS.md section 5: nothing in crates/ knows a hostname).

web/API.md section 5 and the API page said every JSON write needs admin. Creating a
repository and starting an op need write (admin.rs, ui.rs); deleting a repository and
writing policy or settings need admin (admin.rs, policy.rs, settings.rs). The page also
had no row for settings and dropped the /api segment from every repository path.
API.md, docs/CONTRACT.md and the SDK comment promised an [integrations] settings section
that walgit-config rejects; the section 6 checklist gave browser_base as /api/v1 instead
of /api-browser/v1; the overview shape pointed at a Go file that does not exist; the
bundle design doc still named /services/install.sh.

Tests: api_v1 asserts docs is derived from the discovery base, and a new test pins the
write gates (a write token gets 403 on PUT and DELETE of policy and settings, an admin
token gets 204 and 200). The walgit-config settings test asserts [integrations] is
refused.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant