Skip to content

docs(api): sync API reference with the b3 router - #153

Merged
ArnobKumarSaha merged 1 commit into
masterfrom
arnob-api-docs
Sep 3, 2026
Merged

docs(api): sync API reference with the b3 router#153
ArnobKumarSaha merged 1 commit into
masterfrom
arnob-api-docs

Conversation

@ArnobKumarSaha

Copy link
Copy Markdown
Member

Adds tooling to diff the b3 API server against docs/platform/api, and applies the drift the first run found.

Tooling

hack/api-doc-sync/, driven by the /api-docs-sync slash command (.claude/commands/api-docs-sync.md). Python 3 stdlib only, except refresh_reference.py which needs PyYAML.

Script Purpose
extract_routes.py Parses b3's macaron registrations into a flat route table. Walks the call graph from RegisterRoutes / RegisterMarketplaceServiceRoutes, so a helper called inside m.Group("/user", …) gets the /user prefix. Handles group nesting + group middlewares, gofmt-wrapped m.Combo(…).Get().Post() chains, bound payload types, inline comments. Currently 547 routes.
compare.py Three-way diff: routes ↔ md pages ↔ openapi.yaml. Resolves the heading conventions these pages use — page-declared roots, PUT · PATCH /x, | POST/GET/DELETE |, /api/v1-prefixed table cells, and abbreviated .../kubeDb/views/x headings.
refresh_reference.py Re-inlines openapi.yaml as JSON into reference/api.html (window.__SPEC__) and updates its paths/operations subtitle. That file was hand-maintained with no generator.

Corrections

  • billing-dashboard/user-dashboard.md had every path wrong. It documented /dashboard/clusters/*, but registerBillingDashboardUserAPIs is called from inside the /user group (routers/api/v1/user.go:66-68) while registering /dashboard/clusters (dashboard.go:70), so the served prefix is /user/dashboard/clusters. Renamed the 10 headings and the 9 matching openapi.yaml paths.
  • The same endpoints require view:licensed_clusters, not view:contracts; the two /events routes additionally require view:event_resources.
  • /healthz and /.well-known/openid-configuration were documented at the host root. Both are registered on the accounts router (routers/routes/routes.go:227-231), which is mounted at /accounts (cmd/api.go:125, AccountsSubURL = "/accounts"). The page's own "Verified 200" note recorded the console SPA catch-all, so it never proved the handler existed. Also replaced the OIDC discovery example with the actual template output.

Newly documented (md + openapi.yaml)

  • GET/POST/PUT/DELETE /orgs/{orgname}/auth-source — the org SSO auth source
  • GET/POST/DELETE /orgs/{orgname}/subscription
  • GET /user/login-method (public), GET /user/orgs, GET /user/inbox/subscriptions
  • POST /user/deploy/orders plus its render/manifest, render/resources, helm3, yaml routes — replacing a placeholder that deferred to the source
  • GET /clusters/{owner}/{cluster}/namespaces/{namespace}/resources
  • the ui.kubedb.com databaseconfigurations raw passthrough
  • GET /dashboard/monthly-summary/{resourceType}

8 new schemas, 13 new spec paths. subscriptions.md also gained the per-verb authorization checks it was missing (subscribe:cluster|namespace|resource, editor vs. viewer).

Verification

  • compare.py end state: code→md 1, code→openapi 1, openapi→code 0. The single entry both times is ANY /*, the /api/v1 catch-all 404 handler — not an endpoint.
  • openapi.yaml parses and every $ref resolves; 456 paths / 544 operations; reference/api.html regenerated to match.
  • liche -p -h -l -s clean on every changed page.
  • The remaining advisory md→code entries are all page-relative overview-table cells, curl examples with concrete values, or {history,status}-style cells — no genuine staleness.

Request/response shapes were derived from the handlers and bound payload types, not guessed. No > **Verified:** notes were added, since nothing here was exercised against a live deployment.

Add tooling to diff the b3 API server against docs/platform/api, and apply
the drift the first run found.

Tooling (hack/api-doc-sync/, driven by /api-docs-sync):

- extract_routes.py walks the macaron registration call graph from
  RegisterRoutes and RegisterMarketplaceServiceRoutes, so a helper called
  inside an m.Group() gets the enclosing path prefix and middlewares.
- compare.py diffs the extracted routes against the md pages and
  openapi.yaml, resolving the page-relative, multi-verb and abbreviated
  heading forms these pages use.
- refresh_reference.py re-inlines openapi.yaml into reference/api.html,
  which had no generator.

Corrections:

- user-dashboard.md documented /dashboard/clusters/*, but
  registerBillingDashboardUserAPIs is called from inside the /user group,
  so the served prefix is /user/dashboard/clusters. Renamed the 10
  headings and the 9 matching openapi.yaml paths.
- The same endpoints require view:licensed_clusters, not view:contracts;
  the two /events routes additionally require view:event_resources.
- /healthz and /.well-known/openid-configuration are registered on the
  accounts router, which is mounted at /accounts - not at the host root as
  documented. Replaced the OIDC example with the actual template output.

Newly documented (md + openapi.yaml):

- /orgs/{orgname}/auth-source (GET/POST/PUT/DELETE)
- /orgs/{orgname}/subscription (GET/POST/DELETE)
- /user/login-method, /user/orgs, /user/inbox/subscriptions
- /user/deploy/orders and its render/helm3/yaml routes, replacing a
  placeholder that deferred to the source
- /clusters/{owner}/{cluster}/namespaces/{namespace}/resources
- the ui.kubedb.com databaseconfigurations raw passthrough
- /dashboard/monthly-summary/{resourceType}

Also records the per-verb authorization checks on the cluster, namespace
and resource subscription routes.

Every route the router registers is now covered by both the md pages and
the spec, except the /api/v1 catch-all 404 handler.

Signed-off-by: Arnob kumar saha <arnob@appscode.com>
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 9e6bcde):

https://kubedb-v2-hugo--pr153-arnob-api-docs-rik4xa4n.web.app

(expires Thu, 10 Sep 2026 10:29:30 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 0f29ae8ae0bd54a99bf2b223b6833be47acd5943

@ArnobKumarSaha
ArnobKumarSaha merged commit dfdb983 into master Sep 3, 2026
6 checks passed
@ArnobKumarSaha
ArnobKumarSaha deleted the arnob-api-docs branch September 3, 2026 10:36
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