# ibm-openapi-validator 中文文档

规范地址：https://npmcn.com/package/ibm-openapi-validator/

版本：1\.38\.6
npm 元数据更新时间：2026-11-03T20:16:22.772Z
中文译文更新时间：2026-11-03T21:23:44.799Z
软件包许可：Apache-2\.0

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

原始 npm 页面：https://www.npmjs.com/package/ibm-openapi-validator
原文对照：https://npmcn.com/package/ibm-openapi-validator/?lang=original
项目主页：https://github.com/IBM/openapi-validator#readme
源码仓库：https://github.com/IBM/openapi-validator

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

- 包体积（解压后）：362 kB，111 个文件
- TypeScript 类型：未声明
- Node.js 要求：\>=16\.0\.0
- 运行依赖：17 个
- 首次发布：2018-10-16T16:35:42.004Z
- 最新版本发布：2026-11-03T20:16:22.536Z
- 已发布版本数：317（近 12 个月 22 个）

## 中文简介

OpenAPI文档的可配置和可扩展的验证器/过滤器

## 安装

```sh
npm install ibm-openapi-validator
```

也可以使用：`pnpm add ibm-openapi-validator`、`yarn add ibm-openapi-validator`、`bun add ibm-openapi-validator`

## README

# OpenAPI验证器

IBM OpenAPI Validator允许您进行验证 [OpenAPI 3.0.x](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md) 和 [OpenAPI里](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md) 遵循OpenAPI规范的文档，以及ibm定义的最佳实践。

注意：本页显示用于入门的缩略用法信息。访问 [这个页面](https://npmcn.com/README.md) 获取完整文档。

## 安装

`npm install -g ibm-openapi-validator`

这个 `-g` Flag全局安装该工具，以便验证器可以从文件系统中的任何位置运行。或者，您可以不传递标志或 `--save-dev` 标志将验证器作为一个依赖项添加到你的项目中，并从你的NPM脚本或JavaScript代码中运行它。

## 用法

### 命令语法

```bash
Usage: lint-openapi [options] [file...]

Run the validator on one or more OpenAPI 3.x documents

Options:
  -c, --config <file>            use configuration stored in <file> (*.json, *.yaml, *.js)
  -e, --errors-only              include only errors in the output and skip warnings (default is false)
  -i, --ignore <file>            avoid validating <file> (e.g. -i /dir1/ignore-file1.json --ignore /dir2/ignore-file2.yaml ...) (default is []) (default: [])
  -j, --json                     produce JSON output (default is text)
  -l, --log-level <loglevel>     set the log level for one or more loggers (e.g. -l root=info -l ibm-schema-description-exists=debug ...)  (default: [])
  -n, --no-colors                disable colorizing of the output (default is false)
  -r, --ruleset <file>           use Spectral ruleset contained in `<file>` ("default" forces use of default IBM Cloud Validation Ruleset)
  -s, --summary-only             include only the summary information and skip individual errors and warnings (default is false)
  -q, --impact-score             compute scores representing the API impact of rule violations and include with the results (default is false)
  -m, --markdown-report          generate a Markdown file with a report on all validator results (default is false)
  -w, --warnings-limit <number>  set warnings limit to <number> (default is -1)
  --version                      output the version number
  -h, --help                     display help for command
```

在 `[file...]` 是一个空格分隔的列表，包含一个或多个OpenAPI 3的文件名。需要验证的X个文档。

## 进一步的阅读

同样，这个页面显示了缩略信息。以下连结可能会有所帮助：

-   [配置选项的详细信息](https://npmcn.com/README.md#configuration)
-   [默认规则集的详细信息](https://npmcn.com/docs/ibm-cloud-rules.md)
-   [有关 `--impact-score` 特征](https://npmcn.com/docs/automated-quality-screening.md)

## 常见问题

### ibm-openapi-validator 是什么？

OpenAPI文档的可配置和可扩展的验证器/过滤器

### 如何安装 ibm-openapi-validator？

在项目目录运行 npm install ibm-openapi-validator，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 lint-openapi，可以用 npx lint-openapi 直接运行。

### ibm-openapi-validator 支持 TypeScript 吗？

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

### ibm-openapi-validator 需要什么版本的 Node\.js？

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

### ibm-openapi-validator 可以商用吗？

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

### ibm-openapi-validator 还在维护吗？

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

