{
  "openapi": "3.1.0",
  "info": {
    "title": "大唐商品供货 API",
    "version": "1.0.0",
    "description": "金额统一为人民币分；商品供货接口，不是模型推理 API。"
  },
  "servers": [
    {
      "url": "/api/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/products": {
      "get": {
        "summary": "可用商品",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "成功；金额为人民币分",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "无效、已撤销或过期密钥"
          },
          "402": {
            "description": "余额不足"
          },
          "409": {
            "description": "报价过期、库存变化或幂等参数冲突"
          },
          "429": {
            "description": "请求过多"
          }
        }
      }
    },
    "/balance": {
      "get": {
        "summary": "账户余额",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "成功；金额为人民币分",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "无效、已撤销或过期密钥"
          },
          "402": {
            "description": "余额不足"
          },
          "409": {
            "description": "报价过期、库存变化或幂等参数冲突"
          },
          "429": {
            "description": "请求过多"
          }
        }
      }
    },
    "/quotes": {
      "post": {
        "summary": "获取报价",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "成功；金额为人民币分",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "无效、已撤销或过期密钥"
          },
          "402": {
            "description": "余额不足"
          },
          "409": {
            "description": "报价过期、库存变化或幂等参数冲突"
          },
          "429": {
            "description": "请求过多"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "product_id",
                  "quantity"
                ],
                "properties": {
                  "product_id": {
                    "type": "string"
                  },
                  "quantity": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders": {
      "get": {
        "summary": "订单列表",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "成功；金额为人民币分",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "无效、已撤销或过期密钥"
          },
          "402": {
            "description": "余额不足"
          },
          "409": {
            "description": "报价过期、库存变化或幂等参数冲突"
          },
          "429": {
            "description": "请求过多"
          }
        }
      },
      "post": {
        "summary": "创建订单",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "成功；金额为人民币分",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "无效、已撤销或过期密钥"
          },
          "402": {
            "description": "余额不足"
          },
          "409": {
            "description": "报价过期、库存变化或幂等参数冲突"
          },
          "429": {
            "description": "请求过多"
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 80
            },
            "description": "同一订单每次重试使用同一个键"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "product_id",
                  "quantity",
                  "quote_id"
                ],
                "properties": {
                  "product_id": {
                    "type": "string"
                  },
                  "quantity": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  },
                  "quote_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders/{id}": {
      "get": {
        "summary": "查询订单及交付",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "成功；金额为人民币分",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "无效、已撤销或过期密钥"
          },
          "402": {
            "description": "余额不足"
          },
          "409": {
            "description": "报价过期、库存变化或幂等参数冲突"
          },
          "429": {
            "description": "请求过多"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "商城订单ID、订单号或客户幂等键"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}
