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:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user