# @ardatan/raml-1-parser 中文文档

规范地址：https://npmcn.com/package/%40ardatan/raml-1-parser/

版本：1\.1\.69
npm 元数据更新时间：2022-04-04T15:22:27.411Z
中文译文更新时间：2026-11-06T18:07:14.972Z
软件包许可：Apache-2\.0

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

原始 npm 页面：https://www.npmjs.com/package/%40ardatan/raml-1-parser
原文对照：https://npmcn.com/package/%40ardatan/raml-1-parser/?lang=original
项目主页：https://github.com/raml-org/raml-js-parser-2
源码仓库：https://github.com/raml-org/raml-js-parser-2

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

- 包体积（解压后）：5.4 MB，410 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=6
- 运行依赖：24 个
- 首次发布：2021-12-05T15:23:06.636Z
- 最新版本发布：2021-12-05T15:55:29.266Z
- 近 30 天下载量：5102（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：2（近 12 个月 0 个）

## 中文简介

[![Build Status](https://travis-ci.org/raml-org/raml-js-parser-2.svg?branch=master)](https://travis-ci.org/raml-org/raml-js-parser-2) [![Greenkeeper badge](https://badges.greenkeeper.io/raml-org/raml-js-parser-2.svg)](https://greenkeeper.io/)

## 安装

```sh
npm install @ardatan/raml-1-parser
```

也可以使用：`pnpm add @ardatan/raml-1-parser`、`yarn add @ardatan/raml-1-parser`、`bun add @ardatan/raml-1-parser`

## README

请注意,这个分析器现在已贬值,请使用 [网络api-parser](https://github.com/raml-org/webapi-parser) 换句话说.

.

# RAML 1.0 JS 解析器

[![Build Status](https://travis-ci.org/raml-org/raml-js-parser-2.svg?branch=master)](https://travis-ci.org/raml-org/raml-js-parser-2) [![Greenkeeper badge](https://badges.greenkeeper.io/raml-org/raml-js-parser-2.svg)](https://greenkeeper.io/)

见 [联合国](http://raml.org/) 关于RAML的更多信息.

这个解析器支持RAML 0.8和1.0.

## 快开始

安装解析器 : `npm install raml-1-parser`

创建新文件测试.js, 代码如下:

```
var raml = require("raml-1-parser");
var apiJSON = raml.load(ramlFileName);
console.log(JSON.stringify(apiJSON, null, 2));
```

地点 `ramlFileName` 是 RAML 文件的路径 .

运行测试 : `node ./test.js`

## 安装

```
npm install raml-1-parser

node node_modules/raml-1-parser/test/test01.js  //synchronously loads XKCD API from local file system and prints its JSON representation
node node_modules/raml-1-parser/test/testAsync01.js  //asynchronously loads XKCD API from local file system and prints its JSON representation
node node_modules/raml-1-parser/test/test02.js  //synchronously loads XKCD API from github and prints its JSON representation
node node_modules/raml-1-parser/test/testAsync02.js  //asynchronously loads XKCD API from github and prints its JSON representation


```

## 使用量

-   对于解析器用法示例参考 `node_modules/raml-1-parser/test/test01.js`
-   对于Asynchrounous使用法,例如: `node_modules/raml-1-parser/test/testAsync01.js`

解析器文档 : [https://raml-org.github.io/raml-js-parser-2. 页面存档备份,存于互联网档案馆](https://raml-org.github.io/raml-js-parser-2/)

Parser JSON 输出计划 : [https://github.com/raml-org/raml-js-parser-2/blob/master/tckJsonSchema/tckJsonSchema.json 页面存档备份,存于互联网档案馆](https://github.com/raml-org/raml-js-parser-2/blob/master/tckJsonSchema/tckJsonSchema.json)

正在获取开始向导 : [https://github.com/raml-org/raml-js-parser-2/blob/master/documentation/GettingStarted.md 互联网档案馆的存檔,存档日期2014-12-2](https://github.com/raml-org/raml-js-parser-2/blob/master/documentation/GettingStarted.md)

高级使用实例: [https://github.com/raml-org/raml-js-parser-2/blob/master/examples/highlevel-AST-usage/tropolitic.md 互联网档案馆的存檔,存档日期2014-12-2](https://github.com/raml-org/raml-js-parser-2/blob/master/examples/highlevel-AST-usage/tutorial.md)

验证插件使用示例 : [https://github.com/raml-org/raml-js-parser-2/blob/master/examples/validation Plugins 互联网档案馆的存檔,存档日期2013-12-2](https://github.com/raml-org/raml-js-parser-2/blob/master/examples/validationPlugins)

## 创建独立的浏览器包

克隆存储器 : `git clone https://github.com/raml-org/raml-js-parser-2.git`

安装模块 : `npm install`

构建 : `npm run build`

生成浏览器包 : `npm run generateBrowserVersion`,这将生成软件包在 `browserVersion` 文件夹.

要生成方便调试的浏览器包 : `npm run generateBrowserVersionDev`

## 建立高级开发环境

克隆存储器 :

-   `git clone https://github.com/mulesoft-labs/yaml-ast-parser.git`
-   `git clone https://github.com/mulesoft-labs/ts-model.git`
-   `git clone https://github.com/mulesoft-labs/ts-structure-parser.git`
-   `git clone https://github.com/raml-org/raml-typesystem.git`
-   `git clone https://github.com/raml-org/raml-definition-system.git`
-   `git clone https://github.com/raml-org/raml-js-parser-2.git`

对于每个寄存器,保存顺序:

-   安装模块 : `npm install`
-   设置 npm 链接 : `npm link`

对于每个寄存器,保存顺序:

-   开放依赖性 : `cd node_modules`
-   每个模块 `<module_name>` 内 `node_modules` 属于上述清单的: `rm -rf <module_name>`
-   每个模块 `<module_name>` 内 `node_modules` 属于上述清单的: `npm link <module_name>`

对于每个寄存器,保存顺序:

-   构建 : `npm run build`

如何测试 : `gulp test`

## 启动TCK测试

执行 `npm run tck` 在赞美的一行. 脚本复制 `master` tCK 寄存器的分支 `TCK` 项目的子文件夹并执行所有测试。 报告文件是 `TCK/report.json`。 。 。 .

## 捐款

如果你有兴趣为这个项目提供一些代码,谢谢! 先请 [阅读和接受《缴款人协定》](https://api-notebook.anypoint.mulesoft.com/notebooks#bc1cf75a0284268407e4)。 。 。 .

为了讨论这个项目,请使用 [问题](https://github.com/raml-org/raml-js-parser-2/issues) 或 [RAML 论坛](http://forums.raml.org/)。 。 。 .

## 常见问题

### 如何安装 @ardatan/raml-1-parser？

在项目目录运行 npm install @ardatan/raml-1-parser，或使用 pnpm add / yarn add / bun add。

### @ardatan/raml-1-parser 支持 TypeScript 吗？

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

### @ardatan/raml-1-parser 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @ardatan/raml-1-parser 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=6。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @ardatan/raml-1-parser 可以商用吗？

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

### @ardatan/raml-1-parser 的下载量有多少？

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

### @ardatan/raml-1-parser 还在维护吗？

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

