{
  "openapi": "3.0.4",
  "info": {
    "title": "api/insurance/attach-policy",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "/"
    },
    {
      "url": "https://api.ati.su"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/gw/insurance/v1/insurances/attach-policy": {
      "post": {
        "tags": [
          "ResponsibilityInsurance"
        ],
        "summary": "Подтверждает оплату пользователя и прикрепляет подписанный страховой полис к заявке по страхованию ответственности.",
        "description": "Операция доступна только для страховок страховой компании, указанной в заявке.\nПосле успешной загрузки статус заявки обновится, пользователю будет начислен кешбэк.",
        "operationId": "post_v1_insurances_attach-policy",
        "requestBody": {
          "description": "Тело запроса с номером полиса и файлом полиса.",
          "content": {
            "application/json-patch+json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/AttachPolicyRequest"
                  }
                ],
                "description": "Модель запроса на прикрепление полиса к заявке страхования ответственности.",
                "example": {
                  "policy_number": "Полис12345",
                  "file": {
                    "file_base64": "JVBERi0xLjQKJ...",
                    "content_type": "application/pdf",
                    "file_name": "Полис_12345.pdf"
                  }
                }
              },
              "example": {
                "policy_number": "Полис12345",
                "file": {
                  "file_base64": "JVBERi0xLjQKJ...",
                  "content_type": "application/pdf",
                  "file_name": "Полис_12345.pdf"
                }
              }
            },
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/AttachPolicyRequest"
                  }
                ],
                "description": "Модель запроса на прикрепление полиса к заявке страхования ответственности.",
                "example": {
                  "policy_number": "Полис12345",
                  "file": {
                    "file_base64": "JVBERi0xLjQKJ...",
                    "content_type": "application/pdf",
                    "file_name": "Полис_12345.pdf"
                  }
                }
              },
              "example": {
                "policy_number": "Полис12345",
                "file": {
                  "file_base64": "JVBERi0xLjQKJ...",
                  "content_type": "application/pdf",
                  "file_name": "Полис_12345.pdf"
                }
              }
            },
            "text/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/AttachPolicyRequest"
                  }
                ],
                "description": "Модель запроса на прикрепление полиса к заявке страхования ответственности.",
                "example": {
                  "policy_number": "Полис12345",
                  "file": {
                    "file_base64": "JVBERi0xLjQKJ...",
                    "content_type": "application/pdf",
                    "file_name": "Полис_12345.pdf"
                  }
                }
              },
              "example": {
                "policy_number": "Полис12345",
                "file": {
                  "file_base64": "JVBERi0xLjQKJ...",
                  "content_type": "application/pdf",
                  "file_name": "Полис_12345.pdf"
                }
              }
            },
            "application/*+json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/AttachPolicyRequest"
                  }
                ],
                "description": "Модель запроса на прикрепление полиса к заявке страхования ответственности.",
                "example": {
                  "policy_number": "Полис12345",
                  "file": {
                    "file_base64": "JVBERi0xLjQKJ...",
                    "content_type": "application/pdf",
                    "file_name": "Полис_12345.pdf"
                  }
                }
              },
              "example": {
                "policy_number": "Полис12345",
                "file": {
                  "file_base64": "JVBERi0xLjQKJ...",
                  "content_type": "application/pdf",
                  "file_name": "Полис_12345.pdf"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Неверные входные данные.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "invalid_input_data",
                  "reason": "Неверные входные данные."
                }
              }
            }
          },
          "401": {
            "description": "Не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "un_authorized",
                  "reason": "Не авторизован"
                }
              }
            }
          },
          "402": {
            "description": "Метод доступен только платным пользователям.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "payment_required",
                  "reason": "Метод доступен только платным пользователям."
                }
              }
            }
          },
          "403": {
            "description": "Отсутствует разрешение.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "forbidden",
                  "reason": "Отсутствует разрешение."
                }
              }
            }
          },
          "404": {
            "description": "Ресурс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "not_found",
                  "reason": "Ресурс не найден"
                }
              }
            }
          },
          "500": {
            "description": "Произошла ошибка во время выполнения запроса.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "internal_error",
                  "reason": "Произошла ошибка во время выполнения запроса."
                }
              }
            }
          },
          "504": {
            "description": "Сервер не ответил во время.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "timeout",
                  "reason": "Сервер не ответил во время."
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Код или тип ошибки.",
            "nullable": true,
            "example": "string"
          },
          "reason": {
            "type": "string",
            "description": "Подробное описание причины ошибки.",
            "nullable": true,
            "example": "string"
          }
        },
        "additionalProperties": false,
        "description": "Модель ошибки ответа API.",
        "example": {
          "error": "string",
          "reason": "string"
        }
      },
      "AttachPolicyRequest": {
        "required": [
          "file",
          "policy_number"
        ],
        "type": "object",
        "properties": {
          "policy_number": {
            "minLength": 1,
            "type": "string",
            "description": "Номер страхового полиса.",
            "example": "Полис12345"
          },
          "file": {
            "allOf": [
              {
                "$ref": "#/components/schemas/FileBase64Dto"
              }
            ],
            "description": "Файл формата base64.",
            "example": {
              "file_base64": "JVBERi0xLjQKJ...",
              "content_type": "application/pdf",
              "file_name": "Полис_12345.pdf"
            }
          }
        },
        "additionalProperties": false,
        "description": "Модель запроса на прикрепление полиса к заявке страхования ответственности.",
        "example": {
          "policy_number": "Полис12345",
          "file": {
            "file_base64": "JVBERi0xLjQKJ...",
            "content_type": "application/pdf",
            "file_name": "Полис_12345.pdf"
          }
        }
      },
      "FileBase64Dto": {
        "required": [
          "file_base64"
        ],
        "type": "object",
        "properties": {
          "file_base64": {
            "minLength": 1,
            "type": "string",
            "description": "Байтовый контент файла формата base64.",
            "example": "JVBERi0xLjQKJ..."
          },
          "content_type": {
            "type": "string",
            "description": "MIME-тип файла.",
            "nullable": true,
            "example": "application/pdf"
          },
          "file_name": {
            "type": "string",
            "description": "Название файла.",
            "nullable": true,
            "example": "Полис_12345.pdf"
          }
        },
        "additionalProperties": false,
        "description": "Файл формата base64.",
        "example": {
          "file_base64": "JVBERi0xLjQKJ...",
          "content_type": "application/pdf",
          "file_name": "Полис_12345.pdf"
        }
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Authorization: Bearer {authorizationToken}"
      }
    }
  }
}