{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "Evaluation",
      "description": "评估测试运行相关操作"
    }
  ],
  "servers": [
    {
      "url": "/api/v1",
      "description": "当前 n8n 实例（自托管版本的内置测试台）"
    },
    {
      "url": "{url}/api/v1",
      "description": "自托管 n8n 实例",
      "variables": {
        "url": {
          "default": "https://example.com"
        }
      }
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    },
    {
      "BearerAuth": []
    },
    {
      "CookieAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-N8N-API-KEY"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "CookieAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "n8n-auth"
      }
    },
    "responses": {
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      },
      "notFound": {
        "description": "未找到指定资源。"
      }
    }
  },
  "paths": {
    "/workflows/{workflowId}/test-runs/{runId}": {
      "get": {
        "operationId": "getTestRun",
        "tags": [
          "Evaluation"
        ],
        "summary": "获取单次测试运行",
        "description": "获取工作流的单次评估测试运行，包括汇总指标和最终结果。",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "工作流的 ID。",
            "name": "workflowId",
            "in": "path"
          },
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "测试运行的 ID。",
            "name": "runId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "new",
                        "running",
                        "completed",
                        "error",
                        "cancelled"
                      ]
                    },
                    "runAt": {
                      "type": "string",
                      "nullable": true,
                      "format": "date-time"
                    },
                    "completedAt": {
                      "type": "string",
                      "nullable": true,
                      "format": "date-time"
                    },
                    "metrics": {
                      "type": "object",
                      "description": "汇总此次运行中所有测试用例收集的指标。",
                      "additionalProperties": true,
                      "nullable": true
                    },
                    "errorCode": {
                      "type": "string",
                      "nullable": true
                    },
                    "errorDetails": {
                      "type": "object",
                      "additionalProperties": true,
                      "nullable": true
                    },
                    "finalResult": {
                      "type": "string",
                      "nullable": true,
                      "enum": [
                        "success",
                        "error",
                        "warning"
                      ],
                      "description": "运行的总体结果，完成后根据其测试用例得出。"
                    },
                    "testCaseCount": {
                      "type": "integer"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "required": [
                    "id",
                    "status",
                    "runAt",
                    "completedAt",
                    "metrics",
                    "errorCode",
                    "errorDetails",
                    "finalResult",
                    "testCaseCount",
                    "createdAt",
                    "updatedAt"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          },
          "404": {
            "$ref": "#/components/responses/notFound"
          }
        }
      }
    }
  }
}
