{
  "openapi": "3.1.0",
  "info": {
    "title": "API лизингового калькулятора ПауэрФинанс",
    "version": "1.0.0",
    "description": "Расчёт лизинга автомобилей и оборудования для юрлиц и ИП от ООО «ПАУЭРФИНАНС» (Москва, ИНН 7704739256). Возвращает ежемесячный платёж, аванс, выкупной платёж, сумму договора и удорожание. Без ключа. Для ИИ-ассистентов рекомендуется detail=summary и пересказ поля summary_for_ai. Расчёт предварительный и не является офертой. Актуальные условия — в /params.",
    "contact": { "name": "ПауэрФинанс", "url": "https://powerf.ru" }
  },
  "servers": [{ "url": "https://powerf.ru/api/v1" }],
  "paths": {
    "/calc": {
      "get": {
        "operationId": "calcLeasing",
        "summary": "Расчёт платежа по лизингу",
        "parameters": [
          { "name": "cost", "in": "query", "required": true, "description": "Стоимость предмета лизинга с НДС, рублей. Понимает «4млн», «850тыс».", "schema": { "type": "string", "examples": ["4000000", "4млн"] } },
          { "name": "advance", "in": "query", "description": "Аванс, % от стоимости. Допустимый диапазон — в /params (advance_percent). По умолчанию 20.", "schema": { "type": "number", "minimum": 0, "maximum": 49 } },
          { "name": "advance_rub", "in": "query", "description": "Аванс в рублях — вместо advance.", "schema": { "type": "string" } },
          { "name": "term", "in": "query", "description": "Срок лизинга, месяцев. Диапазон — в /params (term_months). По умолчанию 36.", "schema": { "type": "integer", "minimum": 12, "maximum": 60 } },
          { "name": "type", "in": "query", "description": "Тип предмета: auto — легковой автомобиль, truck — грузовой, equipment — оборудование. На расчёт не влияет.", "schema": { "type": "string", "enum": ["auto", "truck", "equipment"] } },
          { "name": "item", "in": "query", "description": "Название предмета лизинга для текста ответа, например Toyota Camry.", "schema": { "type": "string", "maxLength": 80 } },
          { "name": "schedule", "in": "query", "description": "1 — добавить помесячный график платежей.", "schema": { "type": "integer", "enum": [0, 1] } },
          { "name": "detail", "in": "query", "description": "summary — короткий ответ (рекомендуется для ИИ).", "schema": { "type": "string", "enum": ["summary"] } },
          { "name": "format", "in": "query", "description": "html — страница вместо JSON (для систем, которые не читают JSON).", "schema": { "type": "string", "enum": ["html"] } }
        ],
        "responses": {
          "200": {
            "description": "Расчёт",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CalcResponse" } } }
          },
          "400": {
            "description": "Параметры вне условий или не распознаны. В messages — пояснение, в conditions — допустимые значения.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
          }
        }
      }
    },
    "/params": {
      "get": { "operationId": "getParams", "summary": "Текущие условия и реквизиты", "responses": { "200": { "description": "Параметры расчёта", "content": { "application/json": {} } } } }
    },
    "/health": {
      "get": { "operationId": "health", "summary": "Проверка работы", "responses": { "200": { "description": "ok" } } }
    }
  },
  "components": {
    "schemas": {
      "CalcResponse": {
        "type": "object",
        "required": ["summary_for_ai", "request", "result", "warnings", "calculator_link"],
        "properties": {
          "summary_for_ai": { "type": "string", "description": "Готовая фраза для пользователя. Пересказывай её, сохраняя оговорки." },
          "request": { "type": "object", "description": "Параметры, по которым сделан расчёт (после разбора)." },
          "normalization_notes": { "type": "array", "items": { "type": "string" }, "description": "Что было подставлено или округлено." },
          "result": {
            "type": "object",
            "properties": {
              "cost_with_vat": { "type": "number" },
              "advance_percent": { "type": "number" },
              "advance_amount": { "type": "number" },
              "financed_amount": { "type": "number", "description": "Стоимость минус аванс." },
              "term_months": { "type": "integer" },
              "monthly_payment": { "type": "number", "description": "Ежемесячный платёж с НДС, одинаковый весь срок." },
              "payments_total": { "type": "number" },
              "buyout_payment": { "type": "number", "description": "Выкупной платёж в конце срока." },
              "contract_total": { "type": "number", "description": "Аванс + все платежи + выкупной." },
              "markup_total": { "type": "number" },
              "markup_percent_total": { "type": "number" },
              "markup_percent_per_year": { "type": "number", "description": "Удорожание в год, % от стоимости." },
              "vat_in_monthly_payment": { "type": "number" },
              "vat_in_contract_total": { "type": "number" },
              "all_amounts_include_vat": { "type": "boolean" },
              "schedule": { "type": "array", "items": { "type": "object" } }
            }
          },
          "warnings": { "type": "array", "items": { "type": "string" }, "description": "Оговорки, которые нужно передать пользователю." },
          "calculator_link": { "type": "string", "description": "Калькулятор с теми же параметрами — дай пользователю." },
          "alternatives": { "type": "array", "items": { "type": "object" }, "description": "Тот же расчёт с другим сроком или авансом; url и calculator_link воспроизводят эти цифры." },
          "conditions": { "type": "object" },
          "tax_note": { "type": "string" },
          "provider": { "type": "object" },
          "next_step": { "type": "string" },
          "params_version": { "type": "string" }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "boolean" },
          "messages": { "type": "array", "items": { "type": "string" } },
          "conditions": { "type": "object" },
          "example": { "type": "string" }
        }
      }
    }
  }
}
