@genapi/pipeline

中文文档
4.1.4发布于 2026/07/29MITTypeScriptES Module构建来源已验证近 30 天下载 3728
原始使用文档
文档目录11 节
  1. Installation
  2. API
  3. Pipeline
  4. compiler(configRead)
  5. config(userConfig)
  6. default(config, original, parser, compiler, generate, dest)
  7. dest(configRead)
  8. generate(configRead, options?)
  9. original(configRead)
  10. formatTypescript(code, options?)
  11. License

@genapi/pipeline

npm version npm downloads

GenAPI pipeline core: config reading, data source fetching, parsing, compilation, generation, and output. Composable for custom generation flows.

Installation

pnpm add @genapi/pipeline

API

Pipeline

compiler(configRead)

Compiles graphs to code string: request and typings for each output.

Example:

compiler(configRead)
configRead.outputs.forEach(o => console.log(o.code))

config(userConfig)

Normalizes pipeline config: output paths, responseType, baseURL, and builds ConfigRead with inputs/outputs.

Example:

const configRead = config(defineConfig({ input: 'openapi.json', output: { main: 'src/api.ts' } }))

default(config, original, parser, compiler, generate, dest)

Builds a GenAPI pipeline from five steps: config → original → parser → compiler → generate → dest.

Example:

const run = pipeline(config, original, parser, compiler, generate, dest)
await run(defineConfig({ input: 'openapi.json', output: { main: 'src/api.ts' } }))

dest(configRead)

Writes output files from configRead.outputs (code to path).

Example:

await dest(configRead)
// Writes configRead.outputs[].code to configRead.outputs[].path

generate(configRead, options?)

Formats code for each output with Prettier.

Example:

await generate(configRead)
await generate(configRead, { printWidth: 100 })

original(configRead)

Fetches source: resolves uri/http/json from configRead.inputs and sets configRead.source. Transforms the source based on parser configuration (wpapi -> swagger2, swagger -> unchanged). Supports YAML source URLs (e.g. .yaml / .yml); uses confbox for parsing (same as undocs).

Example:

await original(configRead)
// configRead.source is set from uri/http/json; wpapi transformed to swagger2 if parser is 'wpapi'

formatTypescript(code, options?)

Formats TypeScript/JavaScript code string with Prettier.

Example:

const formatted = await formatTypescript('const x=1')

License

MIT


🤖 auto updated with automd

版本与发布记录

@genapi/pipeline 共发布 27 个版本,首次发布于 2023/05/05;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
4.1.4latest2026/07/293 个月前
4.1.32026/07/233 个月前
4.1.22026/07/233 个月前
4.1.12026/05/215 个月前
4.1.02026/02/099 个月前
4.0.02026/02/099 个月前

关于 @genapi/pipeline 的常见问题

如何安装 @genapi/pipeline?

在项目目录运行 npm install @genapi/pipeline,或使用 pnpm add / yarn add / bun add。

@genapi/pipeline 支持 TypeScript 吗?

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

@genapi/pipeline 支持 ESM 还是 CommonJS?

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

@genapi/pipeline 可以商用吗?

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

@genapi/pipeline 的下载量有多少?

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

@genapi/pipeline 还在维护吗?

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