openapi: 3.0.0
info:
  title: Dapr PubSub Service API
  description: Set of endpoints to interact with the Dapr PubSub Service.
  contact:
    email: auradev@tid.es
tags:
  - name: dapr
    description: Dapr pub/sub related operations
servers:
  - url: "https://svc-ap-current.auracognitive.com"
    description: ap-current
paths:
  /dapr/subscribe:
    get:
      tags:
        - dapr
        - subscribe
      description: Get the Dapr subscriptions
      operationId: daprSubscribe
      x-router-controller: routes
      parameters:
        - name: correlator
          in: header
          description: Unique identifier of a request to be used as correlator in all systems
          required: false
          schema:
            type: string
            format: uuid
      responses:
        "200":
          $ref: "#/components/responses/DaprSubscribeResponse"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/InternalError"
        "500":
          $ref: "#/components/responses/InternalError"
  /dapr/events:
    post:
      tags:
        - dapr
        - events
      description: Send an event to the Dapr PubSub Service.
      operationId: daprEvents
      x-router-controller: routes
      parameters:
        - name: 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/DaprEvent"
      responses:
        "200":
          $ref: "#/components/responses/DaprEventsResponse"
        "400":
          $ref: "#/components/responses/InvalidRequest"
        "404":
          $ref: "#/components/responses/NotFound"
        "429":
          $ref: "#/components/responses/InternalError"
        "500":
          $ref: "#/components/responses/InternalError"
components:
  responses:
    DaprEventsResponse:
      description: Dapr events response
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/DaprEventsResponse"
    DaprSubscribeResponse:
      description: Dapr subscriptions response
      headers:
        correlator:
          description: Correlation id for the different services
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/DaprSubscriptions"
    InvalidRequest:
      description: Incoming HTTP request format is not valid
      headers:
        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
      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
      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
    DaprEvent:
      type: object
      description: Dapr event object
      properties:
        id:
          type: string
          description: Unique identifier of the event
          format: uuid
        source:
          type: string
          description: Source of the event
        pubsubname:
          type: string
          description: Name of the pubsub
        topic:
          type: string
          description: Name of the topic
        data:
          type: object
          description: Data of the event, can be any JSON object
      additionalProperties: true
    DaprEventsResponse:
      type: object
      description: Dapr events response
      properties:
        status:
          $ref: "#/components/schemas/DaprEventsResponseStatus"
    DaprEventsResponseStatus:
      type: string
      description: Status of the Dapr event processing
      enum:
        - SUCCESS
        - DROP
        - RETRY
    DaprSubscriptions:
      type: array
      description: List of Dapr subscriptions
      items:
        type: object
        properties:
          pubsubname:
            type: string
            description: Name of the pubsub
          topic:
            type: string
            description: Name of the topic
          routes:
            $ref: "#/components/schemas/DaprSubscriptionRoutes"
      required:
        - pubsubname
        - topic
        - routes
    DaprSubscriptionRoutes:
      type: object
      properties:
        default:
          type: string
          description: Default route for the topic
      required:
        - default
