{
  "openapi": "3.0.0",
  "info": {
    "title": "n8n 公共 API",
    "version": "1.1.1"
  },
  "tags": [
    {
      "name": "Promotions",
      "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": {
      "promotionProviderPublicDto.generated": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 36
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "git",
              "gitlab"
            ]
          },
          "authType": {
            "type": "string",
            "enum": [
              "ssh-key",
              "token"
            ]
          },
          "config": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "schemaVersion": {
                    "type": "number",
                    "enum": [
                      1
                    ]
                  },
                  "publicKey": {
                    "type": "string",
                    "minLength": 1
                  },
                  "keyType": {
                    "type": "string",
                    "enum": [
                      "ed25519",
                      "rsa"
                    ]
                  }
                },
                "required": [
                  "schemaVersion",
                  "publicKey",
                  "keyType"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "schemaVersion": {
                    "type": "number",
                    "enum": [
                      1
                    ]
                  }
                },
                "required": [
                  "schemaVersion"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "schemaVersion": {
                    "type": "number",
                    "enum": [
                      1
                    ]
                  },
                  "baseUrl": {
                    "type": "string"
                  }
                },
                "required": [
                  "schemaVersion",
                  "baseUrl"
                ],
                "additionalProperties": false
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "name",
          "type",
          "authType",
          "config",
          "createdAt",
          "updatedAt"
        ]
      }
    },
    "responses": {
      "badRequest": {
        "description": "请求无效，或提供的数据格式错误。"
      },
      "unauthorized": {
        "description": "未授权"
      },
      "forbidden": {
        "description": "禁止访问"
      },
      "notFound": {
        "description": "未找到指定资源。"
      },
      "conflict": {
        "description": "冲突"
      },
      "unsupportedMediaType": {
        "description": "不支持的媒体类型。"
      },
      "serviceUnavailable": {
        "description": "所请求的服务暂时不可用。"
      }
    }
  },
  "paths": {
    "/promotions/providers/{promotionProviderId}": {
      "put": {
        "operationId": "updatePromotionProvider",
        "tags": [
          "Promotions"
        ],
        "summary": "更新晋升提供方",
        "description": "重命名提供方；发送 `auth` 时替换其凭据。Git 主机提供方还可更新基础 URL；API 目标变化时，同一请求必须包含 `auth`。凭据和主机设置的变更会在保存前校验。如果本次更新保存前，其他请求已更改凭据或配置，则返回 409，请重新加载提供方后重试。对于 GitLab，服务使用 n8n 作为 Git 传输用户名，auth.username 可选，任何提供的用户名都会被忽略。普通 Git 令牌认证要求提供 auth.username。新凭据会应用到所有使用此提供方的环境。认证方式不能更改。",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "晋升提供方的 ID。",
            "name": "promotionProviderId",
            "in": "path"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 128
                  },
                  "auth": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "authType": {
                            "type": "string",
                            "enum": [
                              "ssh-key"
                            ]
                          },
                          "keyType": {
                            "type": "string",
                            "enum": [
                              "ed25519",
                              "rsa"
                            ]
                          }
                        },
                        "required": [
                          "authType"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "authType": {
                            "type": "string",
                            "enum": [
                              "token"
                            ]
                          },
                          "username": {
                            "type": "string",
                            "minLength": 1,
                            "description": "普通 Git 令牌认证时必填。对于 GitLab，服务会忽略此字段，使用 n8n 进行 Git 传输。"
                          },
                          "password": {
                            "type": "string",
                            "minLength": 1
                          }
                        },
                        "required": [
                          "authType",
                          "password"
                        ],
                        "additionalProperties": false
                      }
                    ],
                    "type": "object"
                  },
                  "config": {
                    "type": "object",
                    "properties": {
                      "schemaVersion": {
                        "type": "number",
                        "enum": [
                          1
                        ]
                      },
                      "baseUrl": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "schemaVersion",
                      "baseUrl"
                    ],
                    "additionalProperties": false
                  }
                },
                "additionalProperties": false,
                "minProperties": 1
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "操作成功。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/promotionProviderPublicDto.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"
          }
        }
      }
    }
  }
}
