{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "SettingsLdap",
      "description": "LDAP 设置相关操作"
    }
  ],
  "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"
      }
    },
    "parameters": {
      "limit": {
        "name": "limit",
        "in": "query",
        "description": "最多返回的数据项数量。",
        "required": false,
        "schema": {
          "type": "number",
          "default": 100,
          "maximum": 250
        }
      },
      "cursor": {
        "name": "cursor",
        "in": "query",
        "description": "将 cursor 参数设为上次请求响应中的 nextCursor 属性，以进行分页。使用默认值时，获取集合的第一页。更多信息，请参阅分页说明。",
        "required": false,
        "style": "form",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "badRequest": {
        "description": "请求无效，或提供的数据格式错误。"
      },
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      }
    }
  },
  "paths": {
    "/settings/ldap/sync": {
      "get": {
        "operationId": "getLdapSync",
        "tags": [
          "SettingsLdap"
        ],
        "summary": "获取 LDAP 同步历史",
        "description": "获取 LDAP 同步历史，最近记录优先。需要 `ldap:sync` 作用域，并获得 LDAP 功能许可。",
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer",
                            "description": "此次同步运行的唯一标识符。"
                          },
                          "runMode": {
                            "type": "string",
                            "enum": [
                              "dry",
                              "live"
                            ],
                            "description": "此次同步是试运行还是实际应用变更。"
                          },
                          "status": {
                            "type": "string",
                            "description": "同步状态，例如 success 或 error。"
                          },
                          "startedAt": {
                            "type": "string",
                            "format": "date-time",
                            "description": "同步开始的时间戳。"
                          },
                          "endedAt": {
                            "type": "string",
                            "format": "date-time",
                            "description": "同步完成的时间戳。"
                          },
                          "scanned": {
                            "type": "integer",
                            "description": "同步期间扫描的 LDAP 条目数量。"
                          },
                          "created": {
                            "type": "integer",
                            "description": "同步期间新建的用户数量。"
                          },
                          "updated": {
                            "type": "integer",
                            "description": "同步期间更新的现有用户数量。"
                          },
                          "disabled": {
                            "type": "integer",
                            "description": "同步期间禁用的用户数量。"
                          },
                          "error": {
                            "type": "string",
                            "description": "同步失败时的错误消息；成功时为空字符串。"
                          }
                        },
                        "required": [
                          "id",
                          "runMode",
                          "status",
                          "startedAt",
                          "endedAt",
                          "scanned",
                          "created",
                          "updated",
                          "disabled",
                          "error"
                        ],
                        "description": "LDAP 同步历史记录。",
                        "additionalProperties": false
                      }
                    },
                    "nextCursor": {
                      "type": "string",
                      "nullable": true,
                      "description": "将 cursor 参数设为上次请求返回的 nextCursor 属性，以对同步历史进行分页。null 值表示没有更多记录。"
                    }
                  },
                  "required": [
                    "data",
                    "nextCursor"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/badRequest"
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          }
        }
      }
    }
  }
}
