{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "Role",
      "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"
      }
    },
    "schemas": {
      "rolePublicDto.generated": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "displayName": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "systemRole": {
            "type": "boolean"
          },
          "roleType": {
            "type": "string",
            "enum": [
              "project",
              "global"
            ]
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "slug",
          "displayName",
          "description",
          "systemRole",
          "roleType",
          "scopes",
          "createdAt",
          "updatedAt"
        ]
      }
    },
    "responses": {
      "badRequest": {
        "description": "请求无效，或提供的数据格式错误。"
      },
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      },
      "notFound": {
        "description": "未找到指定资源。"
      },
      "unsupportedMediaType": {
        "description": "不支持的媒体类型。"
      }
    }
  },
  "paths": {
    "/roles/{roleSlug}": {
      "put": {
        "operationId": "updateRole",
        "tags": [
          "Role"
        ],
        "summary": "更新自定义角色",
        "description": "替换自定义角色的显示名称、说明和作用域。系统角色不能更新。",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "角色的 slug。",
            "name": "roleSlug",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "displayName": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 100
                  },
                  "description": {
                    "type": "string",
                    "nullable": true,
                    "maxLength": 500
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "displayName",
                  "description",
                  "scopes"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/rolePublicDto.generated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/badRequest"
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          },
          "404": {
            "$ref": "#/components/responses/notFound"
          },
          "415": {
            "$ref": "#/components/responses/unsupportedMediaType"
          }
        }
      }
    }
  }
}
