1.1.22 • Published 3 years ago
@yourenz/umijs-openapi v1.1.22
本项目 Fork 自 openapi2typescript
使用
npm i @yourenz/umijs-openapi
在项目根目录新建 openapi.config.js
const { generateService } = require('@yourenz/umijs-openapi')
generateService({
schemaPath: 'http://petstore.swagger.io/v2/swagger.json',
serversPath: './src',
})
在 package.json
的 script
中添加 api: node openapi.config.js
生成api
npm run api
参数
属性 | 必填 | 备注 | 类型 |
---|---|---|---|
requestLibPath | 否 | 自定义请求方法路径 | string |
requestImportStatement | 否 | 自定义请求方法表达式 | string |
apiPrefix | 否 | api 的前缀 | string |
serversPath | 否 | 生成的文件夹的路径 | string |
schemaPath | 否 | openAPI 3.0 的地址 | string |
projectName | 否 | 项目名称 | string |
namespace | 否 | 命名空间名称 | string |
mockFolder | 否 | mock目录 | string |
include | 否 | 白名单 | string[] |
exclude | 否 | 黑名单 | string[] |