openapi3-ts-generator
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

介绍

GitHub Repo stars npm (scoped) GitHub tag (latest SemVer pre-release)

根据 OpenApi3 文档生成 request 请求代码。

使用

npm i --save-dev openapi3-ts-generator

在项目根目录新建 openapi.config.ts

const { generateService } = require('openapi3-ts-generator')

generateService({
  schemaPath: 'http://petstore.swagger.io/v2/swagger.json',
  servicesPath: './services',
})

package.jsonscript 中添加 openapi:

"openapi": "node openapi.config.ts",

生成api

npm run openapi

参数

属性 必填 备注 类型 默认值
requestLibPath 自定义请求方法路径 string -
requestImportStatement 自定义请求方法表达式 string -
apiPrefix api 的前缀 string -
servicesPath 生成的文件夹的路径 string -
schemaPath openAPI 3.0 的地址 string -
projectName 项目名称 string -
namespace 类型命名空间名称 string APITypes
mockPath mock目录 string -
enumStyle 枚举样式 string-literal | enum string-literal

Readme

Keywords

none

Package Sidebar

Install

npm i openapi3-ts-generator

Weekly Downloads

2

Version

1.1.1

License

MIT

Unpacked Size

138 kB

Total Files

53

Last publish

Collaborators

  • rumengkai
  • shilili1