ibm-openapi-validator

中文文档
1.38.6发布于 2026/11/04Apache-2.0

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

中文使用文档
文档目录4 节
  1. 安装
  2. 用法
  3. 命令语法
  4. 进一步的阅读

OpenAPI验证器

IBM OpenAPI Validator允许您进行验证 OpenAPI 3.0.x 和 OpenAPI里 遵循OpenAPI规范的文档,以及ibm定义的最佳实践。

注意:本页显示用于入门的缩略用法信息。访问 这个页面 获取完整文档。

安装

npm install -g ibm-openapi-validator

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

用法

命令语法

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个文档。

进一步的阅读

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

版本与发布记录

ibm-openapi-validator 共发布 317 个版本,首次发布于 2018/10/17;过去 12 个月发布了 22 个版本。

版本发布日期距今
1.38.6latest2026/11/041 天前
1.38.52026/11/041 天前
1.38.42026/09/181 个月前
1.38.32026/09/091 个月前
1.38.22026/08/033 个月前
1.38.12026/07/273 个月前

其他发布通道:v1-rc → 1.0.0-rc.3。

关于 ibm-openapi-validator 的常见问题

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 和提交记录判断。