@ama-openapi/cli

中文文档
15.2.4发布于 2026/11/05BSD-3-ClauseTypeScriptES Module构建来源已验证近 30 天下载 3446

CLI to manage OpenAPI models

原始使用文档
文档目录10 节
  1. Description
  2. Installation
  3. Global Installation
  4. Usage
  5. Available commands
  6. install command
  7. watch command
  8. generate-schema command
  9. Expose shareable models
  10. Integration

@ama-openapi/cli

[!WARNING] Experimental: This package is available in early access, the final version will be released in v15.

Stable Version Bundle Size

A command-line interface (CLI) tool for managing OpenAPI specifications and their dependencies through manifest files.

Description

The @ama-openapi/cli package provides a CLI tool to automate the installation and management of OpenAPI specifications based on manifest files.
It's part of the AMA OpenAPI ecosystem that helps manage OpenAPI dependencies in your projects.

Installation

Global Installation

npm install @ama-openapi/cli

[!INFO] The package needs to be installed as a dependency to allow model sharing.

Usage

The CLI is available through the ama-openapi command and provides the following functionality:

ama-openapi <command> [options]

The following global options can be used with any command:

OptionTypeDefaultDescription
--log-level, -l"silent" | "error" | "warning" | "info" | "debug"errorDefine the specific level of logs to display in the console
--help, -hShow help information

Available commands

install command

This command scans for manifest files in the current working directory and installs all OpenAPI specifications specified in those files. The installation process will download and process the OpenAPI specifications according to the configuration in your manifest.

ama-openapi install [options]

Examples:

# Install dependencies from manifest files
ama-openapi install

# Install with debug output
ama-openapi install --debug

# Install silently
ama-openapi install --silent

watch command

This command starts a file watcher that monitors manifest files for changes. When a manifest file is modified, it automatically triggers the installation process, ensuring your OpenAPI specifications are always up to date during development.

ama-openapi watch [options]

Examples:

# Start watching manifest files
ama-openapi watch

# Watch with debug output
ama-openapi watch --debug

generate-schema command

Generate the JSON Schemas that can be used for configuration auto completion.

npm exec @ama-openapi/cli generate-schema -- [options]

Options

OptionAliasDescriptionDefault value
--output-oOutput directory where to generate the schemas'./schemas'
--keywords-kList of the keywords to include in the artifact to be considered in the schema generation['openapi']

Expose shareable models

To expose models from the OpenAPI package, the following setups are required:

  • The models/ (or any shareable folder) should be listed in package.json exports field.
  • The models_external/ should be should be listed in package.json exposed folders.
  • The models_external/ folder, with its content, must be present in the installed package

To ensure the correct resolution of the dependencies with the versions required by the final specification, the presence of the models_external/ can be achieved only through a postinstall process.

// package.json file
{
  "name": "@my/spec",
  "scripts": {
    "postinstall": "ama-openapi install"
  }
}

[!NOTE] Find more information regarding the model dependency resolution on @ama-openapi/core documentation.

[!TIP] The repository generator from @ama-openapi/create configures the package to allow the models exposition by default.

Integration

This CLI tool is designed to work seamlessly with:

版本与发布记录

@ama-openapi/cli 共发布 501 个版本,首次发布于 2025/11/01;过去 12 个月发布了 493 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
15.2.4latest2026/11/051 天前
15.4.0-prerelease.5prerelease2026/11/051 天前
15.2.32026/11/041 天前
15.4.0-prerelease.42026/11/041 天前
15.4.0-prerelease.32026/11/023 天前
15.4.0-prerelease.22026/11/023 天前

其他发布通道:next → 14.0.0-next.14,v13-updated → 13.5.13,v14-updated → 14.5.4,v15-updated → 15.1.3,rc → 15.3.0-rc.1,prerelease → 15.4.0-prerelease.5。

关于 @ama-openapi/cli 的常见问题

@ama-openapi/cli 是什么?

CLI to manage OpenAPI models

如何安装 @ama-openapi/cli?

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

@ama-openapi/cli 支持 TypeScript 吗?

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

@ama-openapi/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@ama-openapi/cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.22.3 || ^24.15.0 || ^26.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@ama-openapi/cli 可以商用吗?

@ama-openapi/cli 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@ama-openapi/cli 的下载量有多少?

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

@ama-openapi/cli 还在维护吗?

最新版本 15.2.4 发布于 2026/11/05(1 天前);至今共发布 501 个版本,其中过去 12 个月发布了 493 个;首次发布于 2025/11/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。