@azure-tools/spec-gen-sdk

中文文档
0.9.11发布于 2026/11/07MITTypeScriptCommonJS近 30 天下载 3.7万

A TypeScript implementation of the API specification to SDK tool

原始使用文档

Spec-gen-sdk

Spec-gen-sdk coordinates SDK generation from a local specification repository and a local SDK repository, invoking the language automation configured in the SDK repository's swagger_to_sdk_config.json.

Generate input contract

The configured generateScript receives paths to generateInput.json and generateOutput.json. The input contract is defined by GenerateInputSchema.json.

Callers can optionally pass --typespec-emitter <package-name> to spec-gen-sdk. The value is forwarded unchanged in generateInput.json as typespecEmitter:

{
  "typespecEmitter": "@azure-tools/typespec-ts-provisioning"
}

This is an excerpt, not a complete generate input. The package name is an example; there is no default emitter. When the option is omitted, the serialized input omits typespecEmitter, preserving existing language automation behavior. Programmatic callers can supply the same optional field in SdkAutoOptions.

When a non-empty emitter is selected, spec-gen-sdk requires that emitter to have an enabled (truthy) entry under options (or legacy emitters when options is absent) in tspconfig.yaml and map to the requested SDK repository in the specification repository configuration. Otherwise, it logs a configuration warning and returns notEnabled without invoking language automation. An explicit emitter request requires tspConfigPath and does not fall back to OpenAPI generation through readmePath. Omitted or empty emitter selections preserve the existing repository-level enablement and fallback behavior.

The field does not install the emitter or modify tspconfig.yaml. Language automation must support the field to use it; provisioning pipeline configuration and language-specific generation support are separate changes.

Development

Use Node.js 22.13.0 or later. From this directory, run npm ci to install dependencies, npx tsc --noEmit to type-check, npm run lint to lint, and npm test to run the tests.

版本与发布记录

@azure-tools/spec-gen-sdk 共发布 44 个版本,首次发布于 2024/12/19;过去 12 个月发布了 9 个版本。

版本发布日期距今
0.9.11latest2026/11/07今天
0.9.102026/11/034 天前
0.9.92026/10/2810 天前
0.9.82026/09/091 个月前
0.9.72026/04/116 个月前
0.9.62025/12/2010 个月前

其他发布通道:beta → 0.6.2。

关于 @azure-tools/spec-gen-sdk 的常见问题

@azure-tools/spec-gen-sdk 是什么?

A TypeScript implementation of the API specification to SDK tool

如何安装 @azure-tools/spec-gen-sdk?

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

@azure-tools/spec-gen-sdk 支持 TypeScript 吗?

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

@azure-tools/spec-gen-sdk 支持 ESM 还是 CommonJS?

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

@azure-tools/spec-gen-sdk 需要什么版本的 Node.js?

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

@azure-tools/spec-gen-sdk 可以商用吗?

@azure-tools/spec-gen-sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@azure-tools/spec-gen-sdk 的下载量有多少?

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

@azure-tools/spec-gen-sdk 还在维护吗?

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