> ## Documentation Index
> Fetch the complete documentation index at: https://omer-914cc1c6.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AsyncAPI 设置

> 使用 AsyncAPI 创建 WebSocket 参考文档页

<div id="add-an-asyncapi-specification-file">
  ## 添加 AsyncAPI 规范文件
</div>

要开始为你的 WebSocket 创建页面，请确保你有一份符合 [AsyncAPI 规范](https://www.asyncapi.com/docs/reference/specification/v3.0.0) 的有效 AsyncAPI 架构文档，格式为 JSON 或 YAML。你的架构必须遵循 AsyncAPI 3.0+ 规范。

<Tip>
  要验证你的 AsyncAPI 架构是否有效，你可以将其粘贴到
  [AsyncAPI Studio](https://studio.asyncapi.com/)
</Tip>

<div id="auto-populate-websockets-pages">
  ## 自动生成 WebSocket 页面
</div>

你可以在 `docs.json` 的 navigation 中任意 Tab 或 group 下添加一个 `asyncapi` 字段。该字段可以是你文档仓库中的 AsyncAPI 架构文档路径、已托管的 AsyncAPI 架构文档的 URL，或指向多个 AsyncAPI 架构文档的链接数组。Mintlify 会为每个 AsyncAPI WebSocket 通道自动生成页面。

**含 Tabs 的示例：**

<CodeGroup>
  ```json Local File {5} theme={null}
  "navigation": {
    "tabs": [
      {
          "tab": "API Reference",
          "asyncapi": "/path/to/asyncapi.json"
      }
    ]
  }

  ```

  ```json Remote URL {5} theme={null}
  "navigation": {
    "tabs": [
      {
          "tab": "API Reference",
          "asyncapi": "https://github.com/asyncapi/spec/blob/master/examples/simple-asyncapi.yml"
      }
    ]
  }
  ```
</CodeGroup>

**含 Groups 的示例：**

```json {8-11} theme={null}
"navigation": {
  "tabs": [
    {
      "tab": "AsyncAPI",
      "groups": [
        {
          "group": "Websockets",
          "asyncapi": {
            "source": "/path/to/asyncapi.json",
            "directory": "api-reference"
          }
        }
      ]
    }
  ]
}
```

<Note>
  directory 字段是可选项。若未指定，文件将放置在 docs 仓库的 **api-reference** 文件夹中。
</Note>

<div id="channel-page">
  ## Channel 页面
</div>

如果你需要更精细地控制频道的排序，或只想引用某个单独的频道，你可以创建一个在 frontmatter 中包含 `asyncapi` 字段的 MDX 文件。

```mdx theme={null}
---
title: "Websocket 频道"
asyncapi: "/path/to/asyncapi.json channelName"
---
```
