Skip to content

Add OpenAPI 3.1 specification for ComfyUI API#13397

Open
MillerMedia wants to merge 5 commits intomasterfrom
add-openapi-spec
Open

Add OpenAPI 3.1 specification for ComfyUI API#13397
MillerMedia wants to merge 5 commits intomasterfrom
add-openapi-spec

Conversation

@MillerMedia
Copy link
Copy Markdown

@MillerMedia MillerMedia commented Apr 14, 2026

Summary

  • Adds a comprehensive OpenAPI 3.1 specification (openapi.yaml) documenting all HTTP endpoints exposed by ComfyUI's server
  • Covers prompt execution, queue management, file uploads, userdata, settings, system stats, object info, assets, model management, and internal routes
  • Includes WebSocket message schemas via x-websocket-messages extension
  • Documents dual-path routing (bare paths and /api/ prefix)
  • Removes openapi.yaml from .gitignore so the spec is tracked in version control

Details

The spec was:

  • Written against the current source code (server.py, app/, api_server/)
  • Cross-reviewed against the actual route handlers to catch drift
  • 17 critical/high corrections applied based on code review (e.g., fixing fabricated response fields, correcting query parameter names, adding missing schema properties)
  • Passes Spectral OpenAPI linting with 0 errors and 62 warnings (all cosmetic — missing operation descriptions, etc.)

Endpoints covered

Category Endpoints
Prompt & Queue /api/prompt, /api/queue
History /api/history, /api/history/{prompt_id}
File Operations /api/view, /api/upload/image, /api/upload/mask
System /api/system_stats, /api/interrupt, /api/free
Node Info /api/object_info, /api/object_info/{node_class}
User Data /api/userdata/*, /api/settings, /api/users
Assets /api/assets/*
Models /api/experiment/models/*
Jobs /api/jobs, /api/jobs/{job_id}
Templates /api/workflow_templates
Embeddings /api/embeddings
Extensions /api/extensions
Internal /internal/*

Test plan

  • Validate spec with npx @stoplight/spectral-cli lint openapi.yaml
  • Verify generated client code matches actual server behavior
  • Spot-check 3-5 endpoints against running ComfyUI instance

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

📝 Walkthrough

Walkthrough

The pull request modifies the .gitignore file to remove openapi.yaml from the list of ignored files. This change means that openapi.yaml will now be tracked by version control, whereas previously it was excluded. The filtered-openapi.yaml file remains in the ignore list. This is a minimal change affecting only one line in the configuration file.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding an OpenAPI 3.1 specification for the ComfyUI API, which matches the PR's primary objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The description comprehensively describes the OpenAPI specification being added and the .gitignore change, directly aligning with the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Adds a comprehensive OpenAPI 3.1 spec documenting all HTTP endpoints
exposed by ComfyUI's server, including prompt execution, queue management,
file uploads, userdata, settings, system stats, object info, assets,
and internal routes.

The spec was validated against the source code with adversarial review
from multiple models, and passes Spectral linting with zero errors.

Also removes openapi.yaml from .gitignore so the spec is tracked.
Comment thread openapi.yaml
# ---------------------------------------------------------------------------
# History
# ---------------------------------------------------------------------------
/api/history:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're trying to deprecate this endpoint (in favor of /jobs), do we want to exclude it from the OpenAPI spec?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added deprecated:true and description on this one.

Comment thread openapi.yaml
"200":
description: History updated

/api/history/{prompt_id}:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above -- should we include deprecated endpoints?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added deprecated:true and description on this one.

Copy link
Copy Markdown
Member

@guill guill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me other than either removing or documenting in some way that some endpoints (e.g. /api/history) are deprecated.

Address Jacob's review feedback on PR #13397 by explicitly marking the
three /api/history operations as deprecated in the OpenAPI spec:

  * GET  /api/history              -> superseded by GET /api/jobs
  * POST /api/history              -> superseded by /api/jobs management
  * GET  /api/history/{prompt_id}  -> superseded by GET /api/jobs/{job_id}

Each operation gains deprecated: true plus a description that names the
replacement. A formal sunset timeline (RFC 8594 Deprecation and RFC 8553
Sunset headers, minimum-runway policy) is being defined separately and
will be applied as a follow-up.
@MillerMedia
Copy link
Copy Markdown
Author

Looks good to me other than either removing or documenting in some way that some endpoints (e.g. /api/history) are deprecated.

I've added deprecated to the two endpoints called out. Any other endpoints planned for deprecation?

MillerMedia and others added 2 commits April 14, 2026 13:14
- Add operation descriptions to 52 endpoints (prompt, queue, upload,
  view, models, userdata, settings, assets, internal, etc.)
- Add schema descriptions to 22 component schemas
- Add parameter descriptions to 8 path parameters that were missing them
- Remove 6 unused component schemas: TaskOutput, EmbeddingsResponse,
  ExtensionsResponse, LogRawResponse, UserInfo, UserDataFullInfo

No wire/shape changes. Reduces Spectral findings from 92 to 4. The
remaining 4 are real issues (WebSocket 101 on /ws, loose error schema,
and two snake_case warnings on real wire field names) and are worth
addressing separately.
@MillerMedia
Copy link
Copy Markdown
Author

@guill heads up — ran Spectral against this spec (using our cloud ruleset as a baseline) and pushed a commit (3fcbaee) with the cosmetic fixes it surfaced:

  • Added descriptions to 52 operations, 22 schemas, and 8 path params
  • Removed 6 unused component schemas (TaskOutput, EmbeddingsResponse, ExtensionsResponse, LogRawResponse, UserInfo, UserDataFullInfo)

No wire/shape changes. Findings went from 92 → 4. The remaining 4 are real issues I didn't want to bundle in a cosmetic sweep:

  1. /ws only declares a 101 response (legitimate for WebSocket upgrade, but Spectral wants 2xx/3xx)
  2. PromptErrorResponse uses additionalProperties: true — loose but matches the real server shape
  3. ModelFile.pathIndex — snake_case warning, but it's the actual wire field emitted by app/model_manager.py
  4. ProgressTextWsMessage.nodeId — schema says JSON, but the server actually emits binary here; looks like a deeper protocol bug rather than a naming nit

Happy to follow up on any of those separately.

Comment thread openapi.yaml
Comment on lines +2622 to +2624
oneOf:
- $ref: "#/components/schemas/UserDataResponseFull"
- $ref: "#/components/schemas/UserDataResponseShort"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should really avoid using oneOf without a discriminator. When someone takes this spec and generates an SDK using openapi-generator, the code won't work as expected.

@Kosinkadink
Copy link
Copy Markdown
Member

From my view, this PR and #13410 can go in at any time. As long as everyone's good to go.

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.

4 participants