hlsa-swagger-to-interface
TypeScript icon, indicating that this package has built-in type declarations

0.2.9 • Public • Published

介绍

从umi-openapi 里克隆出来的 地址:https://www.npmjs.com/package/@umijs/openapi
更改了template里的controller模板 让他支持vben格式

使用

npm i --save-dev hlsa-swagger-to-interface

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

const { generateService } = require('hlsa-swagger-to-interface')

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

package.jsonscript 中添加 api: "openapi": "ts-node openapi.config.ts",

生成api

npm run openapi

参数

属性 必填 备注 类型 默认值
requestLibPath 自定义请求方法路径 string -
requestImportStatement 自定义请求方法表达式 string -
apiPrefix api 的前缀 string -
serversPath 生成的文件夹的路径 string -
schemaPath Swagger 2.0 或 OpenAPI 3.0 的地址 string -
projectName 项目名称 string -
namespace 命名空间名称 string API
mockFolder mock目录 string -
enumStyle 枚举样式 string-literal | enum string-literal
nullable 使用null代替可选 boolean false
dataFields response中数据字段 string[] -

Readme

Keywords

none

Package Sidebar

Install

npm i hlsa-swagger-to-interface

Weekly Downloads

0

Version

0.2.9

License

MIT

Unpacked Size

96.1 kB

Total Files

21

Last publish

Collaborators

  • yangzhenxi