{
  "openapi": "3.1.0",
  "info": {
    "title": "Обмены",
    "version": "1"
  },
  "servers": [
    {
      "url": "https://api.x-hub.online/api/v1"
    }
  ],
  "paths": {
    "/exchanges": {
      "post": {
        "operationId": "createExchange",
        "summary": "Создать обмен",
        "security": [
          {
            "apiKey": [],
            "apiSecret": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "UUID (RFC 4122). Повтор с тем же ключом возвращает исходный ресурс."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RequestBody"
              }
            }
          }
        }
      },
      "get": {
        "operationId": "listExchanges",
        "summary": "Список обменов",
        "security": [
          {
            "apiKey": [],
            "apiSecret": []
          }
        ]
      }
    },
    "/exchanges/{id}": {
      "get": {
        "operationId": "getExchange",
        "summary": "Получить обмен",
        "security": [
          {
            "apiKey": [],
            "apiSecret": []
          }
        ]
      }
    },
    "/exchanges/{id}/cancel": {
      "post": {
        "operationId": "cancelExchange",
        "summary": "Отменить обмен",
        "security": [
          {
            "apiKey": [],
            "apiSecret": []
          }
        ]
      }
    },
    "/exchange-clients": {
      "get": {
        "operationId": "listExchangeClients",
        "summary": "Клиенты обмена",
        "security": [
          {
            "apiKey": [],
            "apiSecret": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key"
      },
      "apiSecret": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Secret"
      }
    },
    "schemas": {
      "RequestBody": {
        "type": "object",
        "properties": {
          "amount_usdt": {
            "type": "string",
            "pattern": "^\\d{1,10}(\\.\\d{1,8})?$",
            "description": "Сумма в USDT строкой, не более восьми знаков после точки, строго больше нуля."
          },
          "client_phone": {
            "type": "string",
            "pattern": "^\\+\\d{10,15}$"
          },
          "client_bank_id": {
            "type": "string",
            "minLength": 1
          },
          "external_id": {
            "type": "string",
            "maxLength": 40
          },
          "idempotency_key": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "amount_usdt",
          "client_phone",
          "client_bank_id"
        ],
        "additionalProperties": false
      }
    }
  }
}
