Commit Graph

1 Commits

Author SHA1 Message Date
Claude 91ec18778a
Serve the OpenAPI spec and browsable API docs behind a flag
openapi.yaml has been linted in CI but never reachable over HTTP. Add
--enable-api-docs (off by default) to serve it at /openapi.yaml and render
it at /api-docs.

The viewer is Redoc rather than Swagger UI specifically because it has no
request-execution feature. The local server is unauthenticated by default,
so a docs page with "Try it out" would give one-click access to
/api/interrupt, /api/free and DELETE /api/userdata/{file}.

Notes on the implementation:

- Routes are registered on PromptServer's route table, not on the app, so
  they land before the web.static('/') catch-all that would shadow them.
  This also means they are served at both /openapi.yaml and
  /api/openapi.yaml; the docs page references the spec by a relative URL so
  it resolves from either mount point.
- The spec path resolves from __file__, since ComfyUI is routinely launched
  from other directories.
- Cache headers are set explicitly: the cache_control middleware only
  special-cases js/css/images, so a .yaml response would otherwise be
  served stale after an edit.
- /docs is left alone; it already serves embedded node help content.

The Redoc bundle comes from a pinned CDN URL, so the page needs outbound
network access. Offline installs still get the spec itself, and the page
degrades to a notice pointing at it.

Claude-Session: https://claude.ai/code/session_01BvUveU9ofyGrSz3QxYeecB
2026-08-14 23:43:05 +00:00