ComfyUI/tests-api
bymyself 1eb00c0a51 Upgrade to OpenAPI 3.1.0 with prefixItems and streamlined validation
- Upgraded OpenAPI spec from 3.0.3 to 3.1.0
- Replaced QueueItem oneOf pattern with prefixItems for precise tuple validation
- Simplified GitHub Actions workflow to use only Python tests (removed redundant swagger-editor validation)
- All validation now handled by openapi-spec-validator which supports OpenAPI 3.1
- QueueItem now enforces exact tuple structure: [position, prompt_id, prompt, extra_data, outputs_to_execute]
2025-07-20 19:49:41 -07:00
..
utils [tests] Update API tests to use /api prefix 2025-06-28 22:30:37 -07:00
conftest.py [api] Add /api prefix to all paths in OpenAPI spec 2025-06-29 18:36:51 -07:00
openapi.yaml Upgrade to OpenAPI 3.1.0 with prefixItems and streamlined validation 2025-07-20 19:49:41 -07:00
README.md [docs] Add OpenAPI specification and test framework 2025-05-20 12:15:46 -07:00
requirements.txt [docs] Add OpenAPI specification and test framework 2025-05-20 12:15:46 -07:00
test_api_by_tag.py Fix linting issues in API tests 2025-05-20 12:26:56 -07:00
test_endpoint_existence.py [api] Add /api prefix to all paths in OpenAPI spec 2025-06-29 18:36:51 -07:00
test_schema_validation.py [api] Add /api prefix to all paths in OpenAPI spec 2025-06-29 18:36:51 -07:00
test_spec_validation.py [api] Add /api prefix to all paths in OpenAPI spec 2025-06-29 18:36:51 -07:00

ComfyUI API Testing

This directory contains tests for validating the ComfyUI OpenAPI specification against a running instance of ComfyUI.

Setup

  1. Install the required dependencies:
pip install -r requirements.txt
  1. Make sure you have a running instance of ComfyUI (default: http://127.0.0.1:8188)

Running the Tests

Run all tests with pytest:

cd tests-api
pytest

Run specific test files:

pytest test_spec_validation.py
pytest test_endpoint_existence.py
pytest test_schema_validation.py
pytest test_api_by_tag.py

Run tests with more verbose output:

pytest -v

Test Categories

The tests are organized into several categories:

  1. Spec Validation: Validates that the OpenAPI specification is valid.
  2. Endpoint Existence: Tests that the endpoints defined in the spec exist on the server.
  3. Schema Validation: Tests that the server responses match the schemas defined in the spec.
  4. Tag-Based Tests: Tests that the API's tag organization is consistent.

Using a Different Server

By default, the tests connect to http://127.0.0.1:8188. To test against a different server, set the COMFYUI_SERVER_URL environment variable:

COMFYUI_SERVER_URL=http://example.com:8188 pytest

Test Structure

  • conftest.py: Contains pytest fixtures used by the tests.
  • utils/: Contains utility functions for working with the OpenAPI spec.
  • test_*.py: The actual test files.
  • resources/: Contains resources used by the tests (e.g., sample workflows).

Extending the Tests

To add new tests:

  1. For testing new endpoints, add them to the appropriate test file based on their category.
  2. For testing more complex functionality, create a new test file following the established patterns.

Notes

  • Tests that require a running server will be skipped if the server is not available.
  • Some tests may fail if the server doesn't match the specification exactly.
  • The tests don't modify any data on the server (they're read-only).