# @api-components/api-annotation-document 中文文档

规范地址：https://npmcn.com/package/%40api-components/api-annotation-document/

版本：4\.2\.2
npm 元数据更新时间：2026-04-07T19:29:32.187Z
中文译文更新时间：2026-11-06T13:25:56.362Z
软件包许可：Apache-2\.0

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

原始 npm 页面：https://www.npmjs.com/package/%40api-components/api-annotation-document
原文对照：https://npmcn.com/package/%40api-components/api-annotation-document/?lang=original
项目主页：https://github.com/advanced-rest-client/api-annotation-document#readme
源码仓库：https://github.com/advanced-rest-client/api-annotation-document

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

- 包体积（解压后）：18.2 kB，10 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：未声明
- 运行依赖：4 个
- 首次发布：2018-05-18T22:37:10.815Z
- 最新版本发布：2021-10-27T18:43:04.814Z
- 近 30 天下载量：3141（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：14（近 12 个月 0 个）

## 中文简介

基于 AMF 数据模型生成 RAML 注释的元素

## 安装

```sh
npm install @api-components/api-annotation-document
```

也可以使用：`pnpm add @api-components/api-annotation-document`、`yarn add @api-components/api-annotation-document`、`bun add @api-components/api-annotation-document`

## README

# 被否决

这一部分正在贬值。 代码基础已移动到 [api 文档](https://github.com/advanced-rest-client/api-documentation) 模块。 此模块将在 [第37号共和国文件](https://github.com/advanced-rest-client/api-documentation/pull/37) 合并.

* * *

基于AMF数据模型生成 RAML 注释的元素 .

[![Published on NPM](https://img.shields.io/npm/v/@api-components/api-annotation-document.svg)](https://www.npmjs.com/package/@api-components/api-annotation-document)

[![Tests and publishing](https://github.com/advanced-rest-client/api-annotation-document/actions/workflows/deployment.yml/badge.svg)](https://github.com/advanced-rest-client/api-annotation-document/actions/workflows/deployment.yml)

## 版本兼容性

此版本仅与AMF模式版本2(AMF parser QQ 4.0.0)相通. 用于与上一个模型版本的兼容性 `3.x.x` 版本的组件.

## 使用量

### 安装

```sh
npm install --save @api-components/api-annotation-document
```

元素需要设置 `amf` 属性,并带有完整的生成的AMF模型,以正确解决紧凑的JSON模型. 它还要求设置 `shape` 属性到当前记录的 API 属性(端点、方法、类型(包括类型属性)、安全、安全设置等).

### 在 html 文件内

```html
<html>
  <head>
    <script type="module">
      import '@api-components/api-annotation-document/api-annotation-document.js';
    </script>
  </head>
  <body>
    <api-annotation-document></api-annotation-document>
    <script>
    {
      const model = await getAmfModelSomehow();
      const shape = computeCurrentShape(model, someId);
      const aad = document.querySelector('api-annotation-document');
      aad.amf = model;
      aad.shape = shape;
    }
    </script>
  </body>
</html>
```

### 在一个LitElement中

```js
import { LitElement, html } from 'lit-element';
import '@api-components/api-annotation-document/api-annotation-document.js';

class SampleElement extends LitElement {
  render() {
    return html`
    <api-annotation-document
      .amf="${this.model}"
      .shape="${this.shape}"
    ></api-annotation-document>
    `;
  }
}
customElements.define('sample-element', SampleElement);
```

## 发展

```sh
git clone https://github.com/advanced-rest-client/api-annotation-document
cd api-annotation-document
npm install
```

### 本地运行演示

```sh
npm start
```

### 运行测试

```sh
npm test
```

## 常见问题

### @api-components/api-annotation-document 是什么？

基于 AMF 数据模型生成 RAML 注释的元素

### 如何安装 @api-components/api-annotation-document？

在项目目录运行 npm install @api-components/api-annotation-document，或使用 pnpm add / yarn add / bun add。

### @api-components/api-annotation-document 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/api-components\_\_api-annotation-document 是否存在。

### @api-components/api-annotation-document 支持 ESM 还是 CommonJS？

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

### @api-components/api-annotation-document 可以商用吗？

@api-components/api-annotation-document 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @api-components/api-annotation-document 的下载量有多少？

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

### @api-components/api-annotation-document 还在维护吗？

最新版本 4\.2\.2 发布于 2021/10/28（5 年前）；至今共发布 14 个版本，其中过去 12 个月发布了 0 个；首次发布于 2018/05/19。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

