Add an API reference page to the web UI

/apireference lists the REST operations (from the same route list and tool
schemas as the OpenAPI document) with access, parameters and a curl example
for this router. Linked from the API access page.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV9dZrK6nipHkPfyM4F
This commit is contained in:
2026-11-01 19:40:45 +01:00
co-authored by Claude Sonnet 5.5
parent 6d8e9d4166
commit 42ceb78d2b
6 changed files with 134 additions and 2 deletions
+22
View File
@@ -234,3 +234,25 @@ func TestTokenEditNote(t *testing.T) {
t.Fatalf("stale note: %q", note)
}
}
func TestAPIReference(t *testing.T) {
a, _ := newTestApp(t)
h := a.routes()
if rec := do(h, "GET", "/apireference", nil, nil); rec.Code != http.StatusSeeOther {
t.Fatalf("without a session: %d", rec.Code)
}
cookie := login(t, h)
rec := do(h, "GET", "/apireference", nil, cookie)
body := rec.Body.String()
if rec.Code != 200 {
t.Fatalf("reference: %d", rec.Code)
}
for _, rt := range apiRoutes {
if !strings.Contains(body, rt.path) {
t.Errorf("%s is not on the page", rt.path)
}
}
if !strings.Contains(body, "curl -sk") || !strings.Contains(body, "If-Match") || !strings.Contains(body, "unit=router-pppoe") {
t.Errorf("examples missing")
}
}