# @eventcatalog/generator-asyncapi 中文文档

规范地址：https://npmcn.com/package/%40eventcatalog/generator-asyncapi/

版本：7\.1\.2
npm 元数据更新时间：2026-11-10T13:45:57.478Z
中文译文更新时间：2026-11-14T01:10:29.423Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40eventcatalog/generator-asyncapi
原文对照：https://npmcn.com/package/%40eventcatalog/generator-asyncapi/?lang=original
项目主页：https://github.com/event-catalog/generators#readme
源码仓库：https://github.com/event-catalog/generators

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：638 kB，15 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：14 个
- 首次发布：2024-08-30T10:44:42.440Z
- 最新版本发布：2026-11-10T13:45:57.040Z
- 近 30 天下载量：4045（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：98（近 12 个月 34 个）

## 中文简介

事件Catalog 的 AsyncAPI 生成器

## 安装

```sh
npm install @eventcatalog/generator-asyncapi
```

也可以使用：`pnpm add @eventcatalog/generator-asyncapi`、`yarn add @eventcatalog/generator-asyncapi`、`bun add @eventcatalog/generator-asyncapi`

## README

# 事件Catalog 的 AsyncAPI 生成器

[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com/) ![](https://img.shields.io/github/actions/workflow/status/event-catalog/generator-asyncapi/verify-build.yml) [![](https://dcbadge.limes.pink/api/server/https://discord.gg/3rjaZMmrAm?style=flat)](https://discord.gg/3rjaZMmrAm) [![](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/david-boyne/) [![blog](https://img.shields.io/badge/blog-EDA--Visuals-brightgreen)](https://eda-visuals.boyney.io/?utm_source=event-catalog-gihub) [![blog](https://img.shields.io/badge/license-Dual--License-brightgreen)](https://github.com/event-catalog/generator-asyncapi/blob/main/LICENSE.md)

![header](https://github.com/event-catalog/generators/blob/main/images/asyncapi.jpeg?raw=true)

#### 特性: 以您的 AsyncAPI 文件生成事件Catalogs, 自动版本, 计划下载, 地图到域, 自定义 AsyncAPI 扩展等...

[阅读文档](https://eventcatalog.dev/) | [编辑文档](https://github.com/event-catalog/docs) | [查看演示](https://demo.eventcatalog.dev/docs)

* * *

# 核心特征

-   来自您的 AsyncAPI 文件的文档域、 服务和信件 (% 1)[实例](https://github.com/event-catalog/generators/tree/main/examples/generator-asyncapi)(中文(简体) )
-   \* 视觉建筑([演示](https://demo.eventcatalog.dev/visualiser)(中文(简体) )
-   QQ 下载您的 AsyncAPI 文件及消息计划表 EventCatalog( 例如 Avro, JSON) ([演示](https://demo.eventcatalog.dev/docs/events/InventoryAdjusted/0.0.4)(中文(简体) )
-   • 自定义 MDX 组件([更多信息](https://eventcatalog.dev/docs/development/components/using-components)(中文(简体) )
-   QQ 自动版本您的域、 服务和信件
-   ⭐ [记录您的频道和协议](https://www.eventcatalog.dev/docs/development/plugins/async-api/features#mapping-channels-into-eventcatalog)
-   ⭐ [使用 EventCatalog 扩展名使用您的 AsyncAPI 文件文档查询、命令和事件](https://www.eventcatalog.dev/docs/development/plugins/async-api/features#mapping-messages-events-commands-or-queries)
-   \* 发现特性(搜索、过滤等)([演示](https://demo.eventcatalog.dev/discover/events)(中文(简体) )
-   还有更多...

# 如何运作

[事件目录](https://www.eventcatalog.dev/) 技术是不可知论的,意思是它可以融入任何计划,规格或经纪人.

事件Catalog 支持 [发电机](https://www.eventcatalog.dev/docs/development/plugins/generators)。 。 。 . 生成器是运行到预建的脚本,以便在您的目录中生成内容 。 发电机可以使用 [事件Catalog SDK](https://www.eventcatalog.dev/docs/sdk)。 。 。 .

使用此 AsyncAPI 插件, 您可以将您的 AsyncAPI 文件连接到您的目录 。 这是通过定义您的发电机在您的 `eventcatlaog.config.js` 文档.

```js
...
generators: [
    [
      '@eventcatalog/generator-asyncapi',
      {
        services: [
          { path: path.join(__dirname, 'asyncapi-files', 'orders-service.asyncapi.yml'), id: 'Orders Service'},
          { path: path.join(__dirname, 'asyncapi-files', 'accounts-service.asyncapi.yml'), id: 'Accounts Service', name: 'Awesome Accounts Service')},
          // Fetch AsyncAPI file from an external URL
          { path: "https://raw.githubusercontent.com/event-catalog/generator-asyncapi/refs/heads/main/src/test/asyncapi-files/simple.asyncapi.yml", id: 'Payment Service', name: 'Payment Service')}
        ],
        domain: { id: 'orders', name: 'Orders', version: '0.0.1' },
      },
    ],
  ],
...
```

在此示例中,生成器将读取 `orders-service.asyncapi.yml` 文件并同时从外部 URL 获取 AsyncAPI 文件,并在您的目录中添加服务和信件。 它会把服务添加到域中 `Orders`。 。 。 .

你可以看到一个例子 [事件catalog- ayncapi- 实例](https://github.com/event-catalog/generators/tree/main/examples/generator-asyncapi/blob/main/eventcatalog.config.js) 还原

# 开始

## 安装和配置

_请确定您在 EventCatalog 的最新版本中_。 。 。 .

1.  安装软件包

```sh
@eventcatalog/generator-asyncapi
```

2.  配置您的 `eventcatalog.config.js` 文件 [(见实例)](https://github.com/event-catalog/generators/tree/main/examples/generator-asyncapi/blob/main/eventcatalog.config.js)
    
3.  运行生成命令
    

```sh
npm run generate
```

4.  参见您的新域、 服务和信件, 运行

```sh
npm run dev
```

### 代理服务器设置

配置环境变量 `PROXY_SERVER_URI` 要使用代理服务器. 您可以在下面以 URI 格式示例定义代理设置 :

您也可以将变量放入 `.env` 文档.

```sh
PROXY_SERVER_URI="http://username:password@your-proxy.company.local" npm run generate
```

## 有问题吗?

在这个项目上提出一个 GitHub 问题, 或者联系我们 [我们的 Discord 服务器](https://discord.gg/3rjaZMmrAm)。 。 。 .

## 本地运行项目

1.  清除还原
2.  安装所需的依赖关系 `pnpm i`
3.  运行 “ npx tsx” 示例/ streelights- mqtt/ index.ts
4.  运行测试 `pnpm run tests`

# 许可证

本项目根据以下规定获得许可证: [MIT 许可证](https://npmcn.com/package/%40eventcatalog/generator-asyncapi/LICENSE)。 。 。 .

## 常见问题

### @eventcatalog/generator-asyncapi 是什么？

事件Catalog 的 AsyncAPI 生成器

### 如何安装 @eventcatalog/generator-asyncapi？

在项目目录运行 npm install @eventcatalog/generator-asyncapi，或使用 pnpm add / yarn add / bun add。

### @eventcatalog/generator-asyncapi 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @eventcatalog/generator-asyncapi 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @eventcatalog/generator-asyncapi 可以商用吗？

@eventcatalog/generator-asyncapi 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @eventcatalog/generator-asyncapi 的下载量有多少？

根据 npm 官方下载统计，@eventcatalog/generator-asyncapi 在 2026/10/14 – 2026/11/12 这 30 天内被下载 4,045 次，日均约 135 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @eventcatalog/generator-asyncapi 还在维护吗？

最新版本 7\.1\.2 发布于 2026/11/10（3 天前）；至今共发布 98 个版本，其中过去 12 个月发布了 34 个；首次发布于 2024/08/30。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

