Type the REST API's responses
Every tool now returns a Go struct (apitypes.go) instead of a map, and typeschema.go derives the OpenAPI response schemas from those types by reflection (json, doc and enum tags), so the document cannot drift from what is sent. Text results are documented as text/plain, settings in answers use the typed settings schema, and edits answer with EditResponse. TestResponsesMatchTheirSchemas checks real responses against the generated schemas. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV9dZrK6nipHkPfyM4F
This commit is contained in:
@@ -60,18 +60,18 @@ func (a *app) checkSettings() (any, error) {
|
||||
}
|
||||
break
|
||||
}
|
||||
return map[string]any{"status": "running", "next": "Still evaluating; call check_settings again in a few seconds."}, nil
|
||||
return CheckResponse{Status: "running", Next: "Still evaluating; call check_settings again in a few seconds."}, nil
|
||||
}
|
||||
|
||||
func (a *app) checkReport(r CheckResult, current bool) map[string]any {
|
||||
out := map[string]any{"status": "done", "ok": r.OK, "forTheSavedSettings": current, "checkedAt": r.Time}
|
||||
func (a *app) checkReport(r CheckResult, current bool) CheckResponse {
|
||||
out := CheckResponse{Status: "done", OK: &r.OK, ForTheSavedSettings: ¤t, CheckedAt: &r.Time}
|
||||
if r.OK {
|
||||
out["message"] = "The settings evaluate: the router's assertions pass."
|
||||
out.Message = "The settings evaluate: the router's assertions pass."
|
||||
} else {
|
||||
out["error"] = r.Error
|
||||
out.Error = r.Error
|
||||
}
|
||||
if !current {
|
||||
out["note"] = "The settings changed during or after this check; call check_settings again."
|
||||
out.Note = "The settings changed during or after this check; call check_settings again."
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user