> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-mintlify-add-hello-world-quickstart-48843.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` 的导航中为任意选项卡或分组添加 `asyncapi` 字段。该字段可以是文档仓库中 AsyncAPI 规范文件的路径、已托管的 AsyncAPI 规范文件的 URL，或指向多个 AsyncAPI 规范文件的链接数组。Mintlify 会为每个 AsyncAPI WebSocket 通道自动生成页面。

**选项卡示例：**

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

  ```

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

**分组示例：**

```json {8-11}
"navigation": {
  "tabs": [
    {
      "tab": "AsyncAPI规范",
      "groups": [
        {
          "group": "WebSocket",
          "asyncapi": {
            "source": "/path/to/asyncapi.json",
            "directory": "api-reference"
          }
        }
      ]
    }
  ]
}
```

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

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

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

```mdx
---
title: "WebSocket 频道"
asyncapi: "/path/to/asyncapi.json channelName"
---
```
