1.3.14 • Published 2 years ago

@jinglun/openapi v1.3.14

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

简介

本项目基于@umijs/openapi 改造,如您不需要这些修改的功能,建议使用官方原版

修改

  1. 修改 api 模板(对只有一种入参的情况简化显示)
  2. 新增 swr 模板(配合 swr.js 库)
  3. mock 生成 index 文件方便导出,添加 CJS 和 ES 两种模块风格;schema 中 response.content'application/json'放宽到 response.content*/*
  4. 新增一些自定义 mock 规则

参数

属性必填备注类型
requestLibPath自定义请求方法路径string
requestImportStatement自定义请求方法表达式string
apiPrefixapi 的前缀string
serversPath生成的文件夹的路径string
schemaPathopenAPI 3.0 的地址string
projectName项目名称string
namespace命名空间名称string
mockFoldermock目录string

新增如下配置项

属性必填备注类型
swrLibPathswr库导入的路径string
swrImportStatement自定义swr表达式string
swrNameswr生成的文件夹名string
mockModuleType用于生成 mock文件的module风格,默认 'ES''CJS' | 'ES'

示例

await openAPI.generateService({
    schemaPath: `${__dirname}/example-files/dorm.json`,
    requestLibPath: "import http  from '@/request'",
    swrLibPath: "import useSWR  from '@/libs/swr'",
    serversPath: './servers',
    swrName: 'data',
    mockFolder: './mocks',
    mockModuleType: 'CJS',
});