openapi: 3.0.2
info:
  title: capi
  version: 0.1.0
paths:
  /api/v1/Chat.init:
    post:
      tags:
        - Chat
      summary: Chat Init
      description: 'Инициализация диалога. '
      operationId: chat_init_api_v1_Chat_init_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatInitRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseChatInit'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure400'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure422'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure500'
  /api/v1/Chat.event:
    post:
      tags:
        - Chat
      summary: Chat Event
      description: 'Обработка Event (событие). '
      operationId: chat_event_api_v1_Chat_event_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatEventRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseChatEvent'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure400'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure422'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure500'
  /api/v1/Chat.request:
    post:
      tags:
        - Chat
      summary: Chat Request
      description: 'Обработка Request (реплика). '
      operationId: chat_request_api_v1_Chat_request_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequestRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseChatRequest'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure400'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure422'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure500'
  /api/v1/webhook:
    post:
      tags:
        - Chat
      summary: Webhook
      description: 'Получение сообщения от SAPI. '
      operationId: webhook_api_v1_webhook_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseSuccess'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure400'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure422'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure500'
  /api/v1/Chat.rate:
    post:
      tags:
        - Chat
      summary: Response Rate
      description: Передать оценку ответа бота в SAPI
      operationId: response_rate_api_v1_Chat_rate_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponseRateRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseChatRate'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure400'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure422'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure500'
  /api/v1/Chat.setRate:
    post:
      tags:
        - Chat
      summary: Set Response Rate
      description: Передать оценку ответа бота в SAPI
      operationId: set_response_rate_api_v1_Chat_setRate_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponseRateRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseChatRate'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure400'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure422'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure500'
  /api/v1/Chat.update:
    post:
      tags:
        - Chat
      summary: Sync Request
      operationId: sync_request_api_v1_Chat_update_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatUpdateRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseChatUpdate'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure400'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure422'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseFailure500'
  /health_check:
    get:
      tags:
        - Misc
      summary: Health Check
      description: Server status.
      operationId: health_check_health_check_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
  /startup:
    get:
      tags:
        - Misc
      summary: Method
      description: Server startup.
      operationId: method_startup_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
  /readiness:
    get:
      tags:
        - Misc
      summary: Method
      description: Server readiness.
      operationId: method_readiness_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
  /liveness:
    get:
      tags:
        - Misc
      summary: Method
      description: Server liveness.
      operationId: method_liveness_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
  /:
    get:
      tags:
        - Misc
      summary: Redirect Doc
      description: Documentation redirection.
      operationId: redirect_doc__get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
  /metrics:
    get:
      tags:
        - Misc
      summary: Metrics
      description: Prometheus metrics.
      operationId: metrics_metrics_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
components:
  schemas:
    BaseChatResponse:
      title: BaseChatResponse
      type: object
      properties:
        id:
          title: Id
          type: string
          description: Идентификатор сообщения.
          default: ''
        reqid:
          title: Reqid
          type: string
          description: Идентификатор сообщения.
          default: ''
    ChatEventRequest:
      title: ChatEventRequest
      required:
        - cuid
        - euid
      type: object
      properties:
        cuid:
          title: Cuid
          type: string
          description: Идентификатор чата.
          format: uuid
        euid:
          title: Euid
          type: string
          description: Идентификатор события.
          format: uuid
        context:
          title: Context
          type: object
          description: Контекст.
          default: {}
    ChatInitRequest:
      title: ChatInitRequest
      required:
        - uuid
      type: object
      properties:
        uuid:
          title: Uuid
          type: string
          description: Идентификатор ассистента.
          format: uuid
        cuid:
          title: Cuid
          type: string
          description: Идентификатор чата.
          format: uuid
        context:
          title: Context
          type: object
          description: Контекст.
          default: {}
    ChatInitResponse:
      title: ChatInitResponse
      type: object
      properties:
        name:
          title: Name
          type: string
          description: Название ассистента.
          default: ''
        cuid:
          title: Cuid
          type: string
          description: Идентификатор чата.
          format: uuid
        events:
          title: Events
          type: object
          description: События.
          default: {}
    ChatRequestAnimation:
      title: ChatRequestAnimation
      type: object
      properties:
        type:
          title: Type
          type: string
          description: Тип анимации.
    ChatRequestRequest:
      title: ChatRequestRequest
      required:
        - cuid
        - text
      type: object
      properties:
        cuid:
          title: Cuid
          type: string
          description: Идентификатор чата.
          format: uuid
        text:
          title: Text
          type: string
          description: Реплика пользователя.
        context:
          title: Context
          type: object
          description: Контекст.
          default: {}
    ChatRequestResponse:
      title: ChatRequestResponse
      required:
        - text
        - cuid
        - animation
        - showExpSys
      type: object
      properties:
        id:
          title: Id
          type: string
          description: Идентификатор сообщения.
          default: ''
        reqid:
          title: Reqid
          type: string
          description: Идентификатор сообщения.
          default: ''
        text:
          title: Text
          type: object
          description: Ответ.
        cuid:
          title: Cuid
          type: string
          description: Идентификатор диалога.
          format: uuid
        rubric:
          title: Rubric
          type: string
          description: Рубрика.
        animation:
          title: Animation
          allOf:
            - $ref: '#/components/schemas/ChatRequestAnimation'
          description: Анимация.
        navigation:
          title: Navigation
          type: string
          description: Навигация.
        token:
          title: Token
          type: string
          description: Токен.
        context:
          title: Context
          type: object
          description: Контекст.
          default: {}
        showExpSys:
          title: Showexpsys
          type: string
          description: .
    ChatUpdateRequest:
      title: ChatUpdateRequest
      required:
        - cuid
      type: object
      properties:
        cuid:
          title: Cuid
          type: string
          description: Chat/Dialog UUID
          format: uuid
    ErrorResult:
      title: ErrorResult
      type: object
      properties:
        error_type:
          title: Error Type
          type: string
          description: Тип ошибки.
          default: ''
        error_message:
          title: Error Message
          type: string
          description: Описание ошибки.
          default: ''
        error_data:
          title: Error Data
          anyOf:
            - type: object
            - type: array
              items: {}
          description: Дополнительная информация об ошибке.
    RateContext:
      title: RateContext
      required:
        - rate_type
        - rate_id
        - rating
      type: object
      properties:
        rate_type:
          title: Rate Type
          enum:
            - rate
            - rate nps
          type: string
          description: Оценка шаблона/NPS
        rate_id:
          title: Rate Id
          type: string
          description: uuid оцениваемого сообщения
          format: uuid
        rating:
          title: Rating
          type: string
          description: Оценка
    ResponseChatEvent:
      title: ResponseChatEvent
      required:
        - result
      type: object
      properties:
        id:
          title: Id
          type: string
          description: Успех выполнения операции.
          default: '0'
        result:
          title: Result
          allOf:
            - $ref: '#/components/schemas/ChatRequestResponse'
          description: Ответ.
    ResponseChatInit:
      title: ResponseChatInit
      required:
        - result
      type: object
      properties:
        id:
          title: Id
          type: string
          description: Успех выполнения операции.
          default: '0'
        result:
          title: Result
          allOf:
            - $ref: '#/components/schemas/ChatInitResponse'
          description: Ответ.
    ResponseChatRate:
      title: ResponseChatRate
      required:
        - result
      type: object
      properties:
        id:
          title: Id
          type: string
          description: Успех выполнения операции.
          default: '0'
        result:
          title: Result
          allOf:
            - $ref: '#/components/schemas/BaseChatResponse'
          description: Ответ.
    ResponseChatRequest:
      title: ResponseChatRequest
      required:
        - result
      type: object
      properties:
        id:
          title: Id
          type: string
          description: Успех выполнения операции.
          default: '0'
        result:
          title: Result
          allOf:
            - $ref: '#/components/schemas/ChatRequestResponse'
          description: Ответ.
    ResponseChatUpdate:
      title: ResponseChatUpdate
      type: object
      properties:
        answers:
          title: Answers
          type: array
          items:
            $ref: '#/components/schemas/ResponseChatRequest'
          description: Накопленные ответы
    ResponseFailure400:
      title: ResponseFailure400
      type: object
      properties:
        success:
          title: Success
          type: boolean
          description: Успех выполнения операции.
          default: false
        result:
          title: Результат выполнения операции.
          allOf:
            - $ref: '#/components/schemas/ErrorResult'
          default:
            error_type: Ошибка клиента
            error_message: Клиент допустил ошибку.
    ResponseFailure422:
      title: ResponseFailure422
      type: object
      properties:
        success:
          title: Success
          type: boolean
          description: Успех выполнения операции.
          default: false
        result:
          title: Результат выполнения операции.
          allOf:
            - $ref: '#/components/schemas/ErrorResult'
          default:
            error_type: RequestValidationError
            error_message: |-
              1 validation error for Request
              body -> params -> branch_id
                field required (type=value_error.missing)
            error_data:
              - loc:
                  - body
                  - params
                  - branch_id
                msg: field required
                type: value_error.missing
    ResponseFailure500:
      title: ResponseFailure500
      type: object
      properties:
        success:
          title: Success
          type: boolean
          description: Успех выполнения операции.
          default: false
        result:
          title: Результат выполнения операции.
          allOf:
            - $ref: '#/components/schemas/ErrorResult'
          default:
            error_type: Ошибка сервера
            error_message: Сервер допустил ошибку.
    ResponseRateRequest:
      title: ResponseRateRequest
      required:
        - cuid
        - context
      type: object
      properties:
        cuid:
          title: Cuid
          type: string
          description: UUID чата/диалога
          format: uuid
        context:
          $ref: '#/components/schemas/RateContext'
    ResponseSuccess:
      title: ResponseSuccess
      type: object
      properties:
        id:
          title: Id
          type: string
          description: Успех выполнения операции.
          default: '0'
        result:
          title: Результат выполнения операции.
          default: {}
    WebhookRequest:
      title: WebhookRequest
      type: object
      properties:
        type:
          title: Type
          type: string
          description: Проверка вебхука.
        cuid:
          title: Cuid
          type: string
          description: Идентификатор чата.
          format: uuid
        reqid:
          title: Reqid
          type: string
          description: Идентификатор запроса.
          format: uuid
        message:
          title: Message
          description: Ответ ассистента.
          default: []
        infosrvid:
          title: Infosrvid
          type: string
          description: Идентификатор сообщения.
        context:
          title: Context
          type: object
          description: Контекст.
          default: {}
        commands:
          title: Commands
          type: object
          description: Команды.
          default: {}
