openapi: 3.0.0
info:
  title: NLPAAS API
  description: Set of endpoints related to nlp as a service api
  version: 1.0.0
  contact:
    email: auradev@tid.es
tags:
  - name: nlpaas
    description: Endpoints related to nlp as a service api
servers:
  - url: http://localhost:8989
    description: Local server
  - url: https://svc-ap-current.auracognitive.com
    description: ap-current
paths:
  /aura-services/v2/aiservices/nlp/query:
    post:
      tags:
        - nlpaas
      description: Generate new response from nlp.
      operationId: postNlpResolutionRequest
      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
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NlpaasRequest'
      responses:
        '200':
          $ref: '#/components/responses/ValidRequestNlp'
        '400':
          $ref: '#/components/responses/InvalidRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  responses:
    ValidRequestNlp:
      description: Incoming HTTP request format is 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/ExtendedNlpaasResponse'
    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 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'
  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
    BasicMessage:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          description: Contains the message to be sent
          pattern: ^(?!\s*$).+
          minLength: 1
    NlpaasRequest:
      description: NLPAAS request message
      allOf:
        - $ref: '#/components/schemas/BasicMessage'
        - type: object
          required:
            - application
          properties:
            userId:
              type: string
              description: Identifier of the user sending the message
            application:
              $ref: '#/components/schemas/Application'
            contextFilters:
              description: Contains the context filters of the request
              type: array
              items:
                type: string
    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
    NlpaasResponse:
      description: NLPAAS response
      type: object
      properties:
        intent:
          description: Contains the intent.
          type: string
        entities:
          description: Contains the entities.
          type: array
          items:
            type: object
            required:
              - entity
              - type
            properties:
              entity:
                description: Contains the entity.
                type: string
              score:
                description: Contains the score.
                type: number
              type:
                description: Contains the type.
                type: string
        contextFilters:
          description: Contains the context filters of the request
          type: array
          items:
            type: string
        score:
          description: Contains the score.
          type: number
    ExtendedNlpaasResponse:
      allOf:
        - $ref: '#/components/schemas/NlpaasResponse'
        - type: object
          required:
            - intent
            - entities
          properties:
            options:
              description: Contains the disambiguation options
              type: array
              items:
                $ref: '#/components/schemas/NlpaasResponse'
