{
  "openapi": "3.1.0",
  "info": {
    "title": "媒小宝开放 API",
    "version": "1.0.0",
    "description": "网关地址由平台提供。使用 UTF-8 和小写十六进制签名。业务签名串为 HTTP 大写方法、原始路径及查询串、时间戳、Nonce、SHA-256(原始请求体)，依次用 LF 分隔且末尾无换行。"
  },
  "servers": [
    {
      "url": "https://api.example.com",
      "description": "示例，替换为平台提供的网关地址"
    }
  ],
  "paths": {
    "/open/v1/auth/token": {
      "post": {
        "summary": "换取令牌",
        "operationId": "post_auth_token",
        "security": [],
        "parameters": [],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "const": 0
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "access_token": {
                          "type": "string"
                        },
                        "expires_in": {
                          "type": "integer",
                          "const": 7200
                        }
                      },
                      "required": [
                        "access_token",
                        "expires_in"
                      ]
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "参数无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "签名、令牌或 Nonce 无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "会员、Scope 或来源 IP 无权访问",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "调用配额耗尽",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务暂不可用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "appKey": {
                    "type": "string"
                  },
                  "timestamp": {
                    "type": "integer"
                  },
                  "nonce": {
                    "type": "string",
                    "minLength": 8,
                    "maxLength": 128
                  },
                  "sign": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$"
                  }
                },
                "required": [
                  "appKey",
                  "timestamp",
                  "nonce",
                  "sign"
                ]
              }
            }
          }
        }
      }
    },
    "/open/v1/resources": {
      "get": {
        "summary": "资源列表",
        "operationId": "get_resources",
        "security": [
          {
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "name": "X-App-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            }
          },
          {
            "name": "X-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{8,128}$"
            }
          },
          {
            "name": "X-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10000,
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 15
            }
          },
          {
            "name": "keyword",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "region",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "const": 0
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Resource"
                          }
                        },
                        "page": {
                          "type": "integer"
                        },
                        "pageSize": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "items",
                        "page",
                        "pageSize",
                        "total"
                      ]
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "参数无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "签名、令牌或 Nonce 无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "会员、Scope 或来源 IP 无权访问",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "调用配额耗尽",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务暂不可用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-required-scope": "resources:read"
      }
    },
    "/open/v1/resources/{sourceId}": {
      "get": {
        "summary": "资源详情",
        "operationId": "get_resources_sourceId",
        "security": [
          {
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "name": "X-App-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            }
          },
          {
            "name": "X-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{8,128}$"
            }
          },
          {
            "name": "X-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          {
            "name": "sourceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]*$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "const": 0
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Resource"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "参数无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "签名、令牌或 Nonce 无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "会员、Scope 或来源 IP 无权访问",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "调用配额耗尽",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务暂不可用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "资源或订单不可见",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-required-scope": "resources:read"
      }
    },
    "/open/v1/resources/state": {
      "post": {
        "summary": "查询可售状态",
        "operationId": "post_resources_state",
        "security": [
          {
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "name": "X-App-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            }
          },
          {
            "name": "X-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{8,128}$"
            }
          },
          {
            "name": "X-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "const": 0
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "sourceId": {
                          "type": "string",
                          "pattern": "^[1-9][0-9]*$"
                        },
                        "available": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "sourceId",
                        "available"
                      ]
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "参数无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "签名、令牌或 Nonce 无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "会员、Scope 或来源 IP 无权访问",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "调用配额耗尽",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务暂不可用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-required-scope": "resources:read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sourceId": {
                    "oneOf": [
                      {
                        "type": "string",
                        "pattern": "^[1-9][0-9]*$"
                      },
                      {
                        "type": "integer",
                        "minimum": 1
                      }
                    ]
                  }
                },
                "required": [
                  "sourceId"
                ]
              }
            }
          }
        }
      }
    },
    "/open/v1/orders": {
      "post": {
        "summary": "创建订单并余额支付",
        "operationId": "post_orders",
        "security": [
          {
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "name": "X-App-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            }
          },
          {
            "name": "X-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{8,128}$"
            }
          },
          {
            "name": "X-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{1,128}$"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "const": 0
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "参数无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "签名、令牌或 Nonce 无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "会员、Scope 或来源 IP 无权访问",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "调用配额耗尽",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务暂不可用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "幂等键冲突或状态不允许",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "报价变更、价格类别不支持或余额不足",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-required-scope": "orders:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sourceId": {
                    "oneOf": [
                      {
                        "type": "string",
                        "pattern": "^[1-9][0-9]*$"
                      },
                      {
                        "type": "integer",
                        "minimum": 1
                      }
                    ]
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "content": {
                    "type": "string",
                    "maxLength": 100000
                  },
                  "price": {
                    "oneOf": [
                      {
                        "type": "number",
                        "minimum": 0.01,
                        "maximum": 99999999
                      },
                      {
                        "type": "string",
                        "pattern": "^\\d+(\\.\\d{1,2})?$"
                      }
                    ]
                  },
                  "priceType": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 255,
                    "default": 1
                  },
                  "remark": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 500
                  }
                },
                "required": [
                  "sourceId",
                  "title",
                  "content",
                  "price"
                ]
              }
            }
          }
        }
      }
    },
    "/open/v1/orders/{orderNo}": {
      "get": {
        "summary": "查询订单",
        "operationId": "get_orders_orderNo",
        "security": [
          {
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "name": "X-App-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            }
          },
          {
            "name": "X-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{8,128}$"
            }
          },
          {
            "name": "X-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          {
            "name": "orderNo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "const": 0
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "参数无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "签名、令牌或 Nonce 无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "会员、Scope 或来源 IP 无权访问",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "调用配额耗尽",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务暂不可用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "资源或订单不可见",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-required-scope": "orders:read"
      }
    },
    "/open/v1/orders/{orderNo}/confirm": {
      "post": {
        "summary": "确认验收",
        "operationId": "post_orders_orderNo_confirm",
        "security": [
          {
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "name": "X-App-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            }
          },
          {
            "name": "X-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{8,128}$"
            }
          },
          {
            "name": "X-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          {
            "name": "orderNo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "const": 0
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "参数无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "签名、令牌或 Nonce 无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "会员、Scope 或来源 IP 无权访问",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "调用配额耗尽",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务暂不可用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "资源或订单不可见",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "幂等键冲突或状态不允许",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-required-scope": "orders:write"
      }
    },
    "/open/v1/orders/{orderNo}/feedback": {
      "post": {
        "summary": "提交反馈",
        "operationId": "post_orders_orderNo_feedback",
        "security": [
          {
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "name": "X-App-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            }
          },
          {
            "name": "X-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{8,128}$"
            }
          },
          {
            "name": "X-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          {
            "name": "orderNo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "const": 0
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "参数无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "签名、令牌或 Nonce 无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "会员、Scope 或来源 IP 无权访问",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "调用配额耗尽",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务暂不可用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "资源或订单不可见",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "幂等键冲突或状态不允许",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-required-scope": "orders:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 500
                  }
                },
                "required": [
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/open/v1/account/balance": {
      "get": {
        "summary": "账户余额",
        "operationId": "get_account_balance",
        "security": [
          {
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "name": "X-App-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            }
          },
          {
            "name": "X-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{8,128}$"
            }
          },
          {
            "name": "X-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "const": 0
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "balance": {
                          "type": "string",
                          "pattern": "^\\d+\\.\\d{2}$"
                        },
                        "memberLevel": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "currency": {
                          "type": "string",
                          "const": "CNY"
                        },
                        "sandbox": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "balance",
                        "memberLevel",
                        "currency",
                        "sandbox"
                      ]
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "参数无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "签名、令牌或 Nonce 无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "会员、Scope 或来源 IP 无权访问",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "调用配额耗尽",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务暂不可用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-required-scope": "balance:read"
      }
    },
    "/open/v1/reconciliation": {
      "get": {
        "summary": "交易对账",
        "operationId": "get_reconciliation",
        "security": [
          {
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "name": "X-App-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            }
          },
          {
            "name": "X-Nonce",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{8,128}$"
            }
          },
          {
            "name": "X-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 10000,
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "startDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "endDate",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "integer",
                      "const": 0
                    },
                    "message": {
                      "type": "string"
                    },
                    "requestId": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "orderNo": {
                                "type": "string"
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "PENDING_PAY",
                                  "PENDING_REVIEW",
                                  "PENDING_UPSTREAM",
                                  "REVIEWING",
                                  "PUBLISHING",
                                  "PENDING_CONFIRM",
                                  "PUBLISHED",
                                  "REJECTED",
                                  "CLOSED",
                                  "REFUNDING",
                                  "REFUNDED"
                                ]
                              },
                              "amount": {
                                "type": "string",
                                "pattern": "^\\d+\\.\\d{2}$"
                              },
                              "currency": {
                                "type": "string",
                                "const": "CNY"
                              },
                              "paidAt": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "refunded": {
                                "type": "boolean"
                              }
                            },
                            "required": [
                              "orderNo",
                              "status",
                              "amount",
                              "currency",
                              "paidAt",
                              "refunded"
                            ]
                          }
                        },
                        "page": {
                          "type": "integer"
                        },
                        "pageSize": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        },
                        "timezone": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "items",
                        "page",
                        "pageSize",
                        "total",
                        "timezone"
                      ]
                    }
                  },
                  "required": [
                    "code",
                    "message",
                    "requestId",
                    "data"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "参数无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "签名、令牌或 Nonce 无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "会员、Scope 或来源 IP 无权访问",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "调用配额耗尽",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "服务暂不可用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "x-required-scope": "reconciliation:read"
      }
    }
  },
  "webhooks": {
    "orderEvent": {
      "post": {
        "summary": "订单事件",
        "parameters": [
          {
            "name": "X-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            }
          },
          {
            "name": "X-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "eventId": {
                    "type": "string"
                  },
                  "event": {
                    "type": "string",
                    "enum": [
                      "order.status_changed",
                      "order.confirmed",
                      "order.refunded"
                    ]
                  },
                  "occurredAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "data": {
                    "type": "object",
                    "properties": {
                      "orderNo": {
                        "type": "string"
                      },
                      "status": {
                        "type": "string",
                        "enum": [
                          "PENDING_PAY",
                          "PENDING_REVIEW",
                          "PENDING_UPSTREAM",
                          "REVIEWING",
                          "PUBLISHING",
                          "PENDING_CONFIRM",
                          "PUBLISHED",
                          "REJECTED",
                          "CLOSED",
                          "REFUNDING",
                          "REFUNDED"
                        ]
                      },
                      "amount": {
                        "type": "string",
                        "pattern": "^\\d+\\.\\d{2}$"
                      },
                      "currency": {
                        "type": "string",
                        "const": "CNY"
                      },
                      "sandbox": {
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "orderNo",
                      "status",
                      "amount",
                      "currency",
                      "sandbox"
                    ]
                  }
                },
                "required": [
                  "eventId",
                  "event",
                  "occurredAt",
                  "data"
                ]
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "处理成功（含重复事件）"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "Bearer": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Resource": {
        "type": "object",
        "properties": {
          "sourceId": {
            "type": "string",
            "pattern": "^[1-9][0-9]*$"
          },
          "name": {
            "type": "string"
          },
          "category": {
            "type": "integer"
          },
          "region": {
            "type": [
              "string",
              "null"
            ]
          },
          "available": {
            "type": "boolean"
          },
          "priceOptions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "priceType": {
                  "type": "integer"
                },
                "label": {
                  "type": "string"
                },
                "price": {
                  "oneOf": [
                    {
                      "type": "string",
                      "pattern": "^\\d+\\.\\d{2}$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "priceType",
                "label",
                "price"
              ]
            }
          }
        },
        "required": [
          "sourceId",
          "name",
          "category",
          "region",
          "available",
          "priceOptions"
        ]
      },
      "Order": {
        "type": "object",
        "properties": {
          "orderNo": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "PENDING_PAY",
              "PENDING_REVIEW",
              "PENDING_UPSTREAM",
              "REVIEWING",
              "PUBLISHING",
              "PENDING_CONFIRM",
              "PUBLISHED",
              "REJECTED",
              "CLOSED",
              "REFUNDING",
              "REFUNDED"
            ]
          },
          "amount": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$"
          },
          "currency": {
            "type": "string",
            "const": "CNY"
          },
          "sandbox": {
            "type": "boolean"
          },
          "resultUrl": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "orderNo",
          "status",
          "amount",
          "currency",
          "sandbox",
          "resultUrl"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "enum": [
              40001,
              40101,
              40301,
              40401,
              40901,
              40902,
              42201,
              42202,
              42901,
              50001,
              50301
            ]
          },
          "message": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          },
          "data": {
            "type": "null"
          }
        },
        "required": [
          "code",
          "message",
          "requestId",
          "data"
        ]
      }
    }
  }
}
