asyncapi: "1.0.0"
info:
  title: Sign up email example
  version: "1.0.0"
baseTopic: 'hitch'

servers:
  - url: api.company.com:{port}/{app-id}
    description: Allows you to connect using the MQTT protocol.
    scheme: mqtt
    variables:
      app-id:
        default: demo
        description: You can find your `app-id` in our control panel, under the auth tab.
      port:
        enum:
          - '5676'
          - '5677'
        default: '5676'

topics:
  accounts.1.0.event.user.signup:
    subscribe:
      $ref: "#/components/messages/userSignedUp"
  email.1.0.event.email.sent:
    publish:
      $ref: "#/components/messages/emailSent"

components:
  messages:
    emailSent:
      summary: Email sent to user.
      description: |
        A message notifying that an
        email has been sent to a user.
      payload:
        type: object
        properties:
          user:
            $ref: "#/components/schemas/user"
          content:
            $ref: "#/components/schemas/content"

    userSignedUp:
      summary: A user has signed up.
      payload:
        type: object
        properties:
          user:
            $ref: "#/components/schemas/user"
          signup:
            $ref: "#/components/schemas/signup"
  schemas:
    content:
      title: content
      description: The email content
      type: string
    id:
      title: id
      description: Resource identifier
      type: string
    username:
      title: username
      description: User handle
      type: string
    datetime:
      title: datetime
      description: Date and Time of the message
      type: string
      format: date-time
    user:
      type: object
      required:
        - id
        - username
      properties:
        id:
          description: User Id
          $ref: "#/components/schemas/id"
        full_name:
          description: User's full name
          type: string
        username:
          $ref: "#/components/schemas/username"
    signup:
      type: object
      required:
        - method
        - datetime
      properties:
        method:
          description: Signup method
          type: string
          enum:
            - email
            - facebook
            - twitter
            - github
            - google
        datetime:
          $ref: "#/components/schemas/datetime"
