openapi: 3.0.0
info:
  title: feedback API
  description: Set of endpoints related to feedback-api  
  contact:
    email: auradev@tid.es
tags:
  - name: feedback
    description: Endpoints related to feedback-api.
servers:
  - url: 'http://localhost:8989'
    description: Local server
  - url: 'https://svc-ap-current.auracognitive.com'
    description: ap-current
paths:
  /aura-services/v2/aiservices/sessions/{session_id}/feedback:
    post:
      tags:        
        - feedback 
      description: Endpoint to receive a feedback message.
      operationId: postFeedbackMessage
      x-router-controller: routes
      security:
        - ApiKeyHeaderAuth: [ ]
      parameters:
        - name: correlator
          in: header
          description: Unique identifier of a request to be used as correlator in all systems
          schema:
            type: string
            format: uuid
        - name: x-token-info
          in: header
          description:
            User authentication data. It might contain JWT object, plain or
            encoded (to keep backwards compatibility).
          required: true
          schema:
            type: string        
        - name: x-correlator
          in: header
          description:
            unique identifier of a request to be used as correlator in all
            systems
          required: false
          schema:
            type: string
            format: uuid  
        - name: session_id
          in: path
          description: Session identifier. Unique string that identifies the session.
          required: true
          schema:
            $ref: '#/components/schemas/StringWithoutSpaces'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeedbackApiMessage'
      responses:
        "204":
          description: Successfully feedback message
          headers:
            correlator:
              description: Correlation id for the different services
              schema:
                type: string
          x-correlator:
              description: Correlation id for the different services
              schema:
                type: string
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/InternalError"
        "500":
          $ref: "#/components/responses/InternalError"
components:
  responses:    
    InvalidRequest:
      description: Incoming HTTP request format is not valid
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
        x-correlator:
              description: Correlation id for the different services
              schema:
                type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
    Unauthorized:
      description: Incoming HTTP request authorization is not valid
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
        x-correlator:
              description: Correlation id for the different services
              schema:
                type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
    NotFound:
      description: Incoming HTTP request is not found
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
        x-correlator:
              description: Correlation id for the different services
              schema:
                type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
    InternalError:
      description: Incoming HTTP request produces an internal error
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
        x-correlator:
              description: Correlation id for the different services
              schema:
                type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/AuraError"
  securitySchemes:
    ApiKeyHeaderAuth:
      type: apiKey
      name: Authorization
      in: header
  schemas:
    AuraError:
      type: object
      description: Error response
      properties:
        code:
          type: string
          description: Unique id of the error
        message:
          type: string
          description: Specific and descriptive text of the error
        errors:
          description: With validation error. Swagger error information
          type: array
          items:
            type: object
    FeedbackApiMessage:     
      type: object
      required:            
        - application
        - value
        - msg_corrid
      properties:
        userId:
          type: string
          description: Identifier of the user sending the message
        application:
          $ref: "#/components/schemas/Application"
        value:
          type: boolean
          description: An indicator true/false that signals whether the user considers the response good or not
        msg_corrid:
          example: 79e2646a-a8bb-4355-b79f-42722c066155
          description: Correlator of the request associated with the message for which feedback is given. Unique string that identifies the message.
          allOf:
            - $ref: '#/components/schemas/StringWithoutSpaces'
    Application:
      type: object
      description: Contains the application who is sending the message
      anyOf:
        - properties:
            id:
              description: The application identifier
              type: string
          required:
            - id
        - properties:
            name:
              description: The application name
              type: string
          required:
            - name    
    StringWithoutSpaces:
      type: string
      example: "79e2646a-a8bb-4355-b79f-42722c066155"
      pattern: '^\S+$'
      minLength: 1      
