{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "CommunityPackage",
      "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": {
      "badRequest": {
        "description": "请求无效，或提供的数据格式错误。"
      },
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      }
    }
  },
  "paths": {
    "/community-packages": {
      "get": {
        "operationId": "getInstalledPackages",
        "tags": [
          "CommunityPackage"
        ],
        "summary": "列出已安装的社区包",
        "description": "获取所有已安装的社区包，包括可更新信息。",
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "packageName": {
                        "type": "string",
                        "description": "npm 包名称"
                      },
                      "installedVersion": {
                        "type": "string",
                        "description": "当前安装的版本"
                      },
                      "authorName": {
                        "type": "string",
                        "description": "包作者姓名"
                      },
                      "authorEmail": {
                        "type": "string",
                        "description": "包作者邮箱"
                      },
                      "installedNodes": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "type": {
                              "type": "string"
                            },
                            "latestVersion": {
                              "type": "number"
                            }
                          }
                        },
                        "description": "此包包含的节点"
                      },
                      "createdAt": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "updatedAt": {
                        "type": "string",
                        "format": "date-time"
                      },
                      "updateAvailable": {
                        "type": "string",
                        "description": "可更新到的版本（如有）"
                      },
                      "failedLoading": {
                        "type": "boolean",
                        "description": "此包是否加载失败"
                      }
                    },
                    "required": [
                      "packageName",
                      "installedVersion",
                      "installedNodes",
                      "createdAt",
                      "updatedAt"
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/badRequest"
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          }
        }
      }
    }
  }
}
