{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "NodeTypePolicy",
      "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": {
      "policyAttachmentsPublicDto.generated": {
        "type": "object",
        "properties": {
          "attachments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "policyId": {
                  "type": "string"
                },
                "rules": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1
                      },
                      "action": {
                        "type": "string",
                        "enum": [
                          "allow",
                          "deny",
                          "delegate"
                        ]
                      },
                      "selector": {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "name"
                                ]
                              },
                              "value": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "required": [
                              "kind",
                              "value"
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "kind": {
                                "type": "string",
                                "enum": [
                                  "package"
                                ]
                              },
                              "value": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "required": [
                              "kind",
                              "value"
                            ]
                          }
                        ],
                        "type": "object"
                      }
                    },
                    "required": [
                      "id",
                      "action",
                      "selector"
                    ]
                  }
                },
                "priority": {
                  "type": "integer"
                },
                "isFloor": {
                  "type": "boolean"
                }
              },
              "required": [
                "policyId",
                "rules",
                "priority",
                "isFloor"
              ]
            }
          },
          "version": {
            "type": "integer",
            "minimum": 0,
            "exclusiveMinimum": true
          }
        },
        "required": [
          "attachments",
          "version"
        ]
      }
    },
    "responses": {
      "badRequest": {
        "description": "请求无效，或提供的数据格式错误。"
      },
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      },
      "notFound": {
        "description": "未找到指定资源。"
      },
      "conflict": {
        "description": "冲突"
      },
      "unsupportedMediaType": {
        "description": "不支持的媒体类型。"
      },
      "serviceUnavailable": {
        "description": "所请求的服务暂时不可用。"
      }
    }
  },
  "paths": {
    "/node-type-policies/scopes/{scopeId}/attachments": {
      "put": {
        "operationId": "replaceNodeTypePolicyAttachments",
        "tags": [
          "NodeTypePolicy"
        ],
        "summary": "预览：替换作用域附加的策略文档",
        "description": "**预览**——即使不提升主版本号，也可能出现破坏性变更。\n\n替换作用域上的全部附加关系。作用域已被写入后，`scopeId` 可从该作用域的 `GET` 响应中获取。每个 `policyId` 及每个 `(isFloor, priority)` 组合在列表内都必须唯一。`version` 必须与当前作用域版本匹配。过期版本返回 409，且不作任何更改。成功写入后，作用域版本递增。",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "节点类型策略作用域的 ID。",
            "name": "scopeId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "attachments": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "policyId": {
                          "type": "string",
                          "minLength": 1
                        },
                        "priority": {
                          "type": "integer"
                        },
                        "isFloor": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "policyId",
                        "priority",
                        "isFloor"
                      ]
                    }
                  },
                  "version": {
                    "type": "integer",
                    "minimum": 0
                  }
                },
                "required": [
                  "attachments",
                  "version"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/policyAttachmentsPublicDto.generated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/badRequest"
          },
          "401": {
            "$ref": "#/components/responses/unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/forbidden"
          },
          "404": {
            "$ref": "#/components/responses/notFound"
          },
          "409": {
            "$ref": "#/components/responses/conflict"
          },
          "415": {
            "$ref": "#/components/responses/unsupportedMediaType"
          },
          "503": {
            "$ref": "#/components/responses/serviceUnavailable"
          }
        }
      }
    }
  }
}
