feat: 实现ComfyUI API服务集成
- 添加ComfyUI API数据模型 (comfyui.rs) - 实现HTTP客户端服务层 (comfyui_service.rs) - 创建Tauri命令层 (comfyui_commands.rs) - 集成服务到应用状态管理 - 注册所有API命令到Tauri处理器 - 添加urlencoding依赖 - 支持8个API端点的完整功能 API端点包括: - 工作流管理 (获取/发布/删除) - 工作流执行和规范查询 - 服务器状态监控 - 文件列表管理 - 连接测试和配置管理 遵循四层架构模式: 数据模型 基础设施服务 表示命令 应用状态集成
This commit is contained in:
465
comfyui.json
Normal file
465
comfyui.json
Normal file
@@ -0,0 +1,465 @@
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"info": {
|
||||
"title": "ComfyUI Workflow Service & Management API",
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"paths": {
|
||||
"/api/workflow": {
|
||||
"get": {
|
||||
"summary": "Get All Workflows Endpoint",
|
||||
"operationId": "get_all_workflows_endpoint_api_workflow_get",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"items": {
|
||||
"additionalProperties": true,
|
||||
"type": "object"
|
||||
},
|
||||
"type": "array",
|
||||
"title": "Response Get All Workflows Endpoint Api Workflow Get"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"summary": "Publish Workflow Endpoint",
|
||||
"operationId": "publish_workflow_endpoint_api_workflow_post",
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "Successful Response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/workflow/{workflow_name}": {
|
||||
"delete": {
|
||||
"summary": "Delete Workflow Endpoint",
|
||||
"operationId": "delete_workflow_endpoint_api_workflow__workflow_name__delete",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "workflow_name",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"description": "The full, unique name of the workflow to delete, e.g., 'my_workflow [20250101120000]'",
|
||||
"title": "Workflow Name"
|
||||
},
|
||||
"description": "The full, unique name of the workflow to delete, e.g., 'my_workflow [20250101120000]'"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Validation Error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HTTPValidationError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/run/": {
|
||||
"post": {
|
||||
"summary": "Execute Workflow Endpoint",
|
||||
"operationId": "execute_workflow_endpoint_api_run__post",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "base_name",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"title": "Base Name"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "version",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Version"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true,
|
||||
"title": "Request Data Raw"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Validation Error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HTTPValidationError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/spec/": {
|
||||
"get": {
|
||||
"summary": "Get Workflow Spec Endpoint",
|
||||
"operationId": "get_workflow_spec_endpoint_api_spec__get",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "base_name",
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"title": "Base Name"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "version",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"title": "Version"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Validation Error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HTTPValidationError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/servers/status": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Server Monitoring"
|
||||
],
|
||||
"summary": "Get Servers Status Endpoint",
|
||||
"description": "获取所有已配置的ComfyUI服务器的配置信息和实时状态。",
|
||||
"operationId": "get_servers_status_endpoint_api_servers_status_get",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ServerStatus"
|
||||
},
|
||||
"type": "array",
|
||||
"title": "Response Get Servers Status Endpoint Api Servers Status Get"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/servers/{server_index}/files": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Server Monitoring"
|
||||
],
|
||||
"summary": "List Server Files Endpoint",
|
||||
"description": "获取指定ComfyUI服务器的输入和输出文件夹中的文件列表。",
|
||||
"operationId": "list_server_files_endpoint_api_servers__server_index__files_get",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "server_index",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"description": "服务器在配置列表中的索引",
|
||||
"title": "Server Index"
|
||||
},
|
||||
"description": "服务器在配置列表中的索引"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/ServerFiles"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"422": {
|
||||
"description": "Validation Error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HTTPValidationError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/": {
|
||||
"get": {
|
||||
"summary": "Read Root",
|
||||
"description": "提供一个API的快速使用指南。",
|
||||
"operationId": "read_root__get",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"FileDetails": {
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"title": "Name"
|
||||
},
|
||||
"size_kb": {
|
||||
"type": "number",
|
||||
"title": "Size Kb"
|
||||
},
|
||||
"modified_at": {
|
||||
"type": "string",
|
||||
"format": "date-time",
|
||||
"title": "Modified At"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"size_kb",
|
||||
"modified_at"
|
||||
],
|
||||
"title": "FileDetails"
|
||||
},
|
||||
"HTTPValidationError": {
|
||||
"properties": {
|
||||
"detail": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ValidationError"
|
||||
},
|
||||
"type": "array",
|
||||
"title": "Detail"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"title": "HTTPValidationError"
|
||||
},
|
||||
"ServerFiles": {
|
||||
"properties": {
|
||||
"server_index": {
|
||||
"type": "integer",
|
||||
"title": "Server Index"
|
||||
},
|
||||
"http_url": {
|
||||
"type": "string",
|
||||
"title": "Http Url"
|
||||
},
|
||||
"input_files": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/FileDetails"
|
||||
},
|
||||
"type": "array",
|
||||
"title": "Input Files"
|
||||
},
|
||||
"output_files": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/FileDetails"
|
||||
},
|
||||
"type": "array",
|
||||
"title": "Output Files"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"required": [
|
||||
"server_index",
|
||||
"http_url",
|
||||
"input_files",
|
||||
"output_files"
|
||||
],
|
||||
"title": "ServerFiles"
|
||||
},
|
||||
"ServerQueueDetails": {
|
||||
"properties": {
|
||||
"running_count": {
|
||||
"type": "integer",
|
||||
"title": "Running Count"
|
||||
},
|
||||
"pending_count": {
|
||||
"type": "integer",
|
||||
"title": "Pending Count"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"required": [
|
||||
"running_count",
|
||||
"pending_count"
|
||||
],
|
||||
"title": "ServerQueueDetails"
|
||||
},
|
||||
"ServerStatus": {
|
||||
"properties": {
|
||||
"server_index": {
|
||||
"type": "integer",
|
||||
"title": "Server Index"
|
||||
},
|
||||
"http_url": {
|
||||
"type": "string",
|
||||
"title": "Http Url"
|
||||
},
|
||||
"ws_url": {
|
||||
"type": "string",
|
||||
"title": "Ws Url"
|
||||
},
|
||||
"input_dir": {
|
||||
"type": "string",
|
||||
"title": "Input Dir"
|
||||
},
|
||||
"output_dir": {
|
||||
"type": "string",
|
||||
"title": "Output Dir"
|
||||
},
|
||||
"is_reachable": {
|
||||
"type": "boolean",
|
||||
"title": "Is Reachable"
|
||||
},
|
||||
"is_free": {
|
||||
"type": "boolean",
|
||||
"title": "Is Free"
|
||||
},
|
||||
"queue_details": {
|
||||
"$ref": "#/components/schemas/ServerQueueDetails"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"required": [
|
||||
"server_index",
|
||||
"http_url",
|
||||
"ws_url",
|
||||
"input_dir",
|
||||
"output_dir",
|
||||
"is_reachable",
|
||||
"is_free",
|
||||
"queue_details"
|
||||
],
|
||||
"title": "ServerStatus"
|
||||
},
|
||||
"ValidationError": {
|
||||
"properties": {
|
||||
"loc": {
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "integer"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "array",
|
||||
"title": "Location"
|
||||
},
|
||||
"msg": {
|
||||
"type": "string",
|
||||
"title": "Message"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"title": "Error Type"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"required": [
|
||||
"loc",
|
||||
"msg",
|
||||
"type"
|
||||
],
|
||||
"title": "ValidationError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user