asyncapi: 3.0.0
info:
  title: 测试 websocket 架构
  version: 1.0.0
  description: 这是一个测试 websocket API。
channels:
  channelOne:
    title: 测试通道
    description: >-
      这是一个 websocket 通道。

      描述中可以包含 _markdown_。

      * 使用 "echo-websocket.hoppscotch.io" 服务器每秒接收带时间戳的消息。
      
      * 使用 "echo.websocket.org" 服务器向 websocket 发送测试消息。此服务器将回显您发送的任何消息。

    address: /
    messages:
      TestMessage:
        $ref: '#/components/messages/TestMessage'
      Timestamp:
        $ref: '#/components/messages/Timestamp'
servers:
  echo-websocket:
    host: echo-websocket.hoppscotch.io
    protocol: wss
  echo:
    host: echo.websocket.org
    protocol: wss
operations:
  sendTestMessage:
    action: receive
    channel:
      $ref: '#/channels/channelOne'
    messages:
      - $ref: '#/channels/channelOne/messages/TestMessage'
  receiveTestMessage:
    action: send
    channel:
      $ref: '#/channels/channelOne'
    messages:
      - $ref: '#/channels/channelOne/messages/TestMessage'
  receiveTimestamp:
    action: send
    channel:
      $ref: '#/channels/channelOne'
    messages:
      - $ref: '#/channels/channelOne/messages/Timestamp'
components:
  messages:
    TestMessage:
      title: 测试消息
      description: 发送到回显服务器的测试消息
      payload:
        type: object
        properties:
          text:
            type: string
            description: 您消息的文本内容
          subtext:
            type: string
            description: 可选的第二个消息字段
          from:
            type: string
            description: 发送者的名称
        required:
          - text
    Timestamp:
      title: 时间戳
      description: 从 echo hoppscotch 服务器发送的时间戳消息
      payload:
        schema:
          $ref: '#/components/schemas/Timestamp'
  schemas:
    Timestamp:
      type: string
      description: 从 echo hoppscotch 服务器发送的时间戳消息
      examples:
        - '22:02:27 GMT+0000 (Coordinated Universal Time)'
