jr-codegen
v1.1.5
Published
生成工具
Downloads
2
Maintainers
Readme
生成 api
jr-codegen api -o ./swagger/api -r http://cloud-his-server.dev.medway.cloud
options
-o, --out <path> path:生成代码输出路径
-r, --remote <remoteUrl>, remoteUrl: 远端swagger json地址
生成枚举
jr-codegen enum -o ./swagger/enum -r http://cloud-his-server.dev.medway.cloud
options
-o, --out <path> path:生成代码输出路径
-r, --remote <remoteUrl> remoteUrl: 远端swagger json地址
-u, --uri <uri> uri: 枚举资源地址 默认值:/api/v1/sys/enums
编译 ts
安装 ts 环境
yarn add typescript --dev
创建 tsconfig
// swagger/tsconfig.json
{
"compilerOptions": {
/* Basic Options */
"strict": true,
"target": "esnext",
"module": "esnext",
"lib": ["es2017", "dom"],
"declaration": true /* Generates corresponding '.d.ts' file. */,
"sourceMap": false /* Generates corresponding '.map' file. */,
"outDir": "../src" /* Redirect output structure to the directory. */,
"rootDir": "./" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
"moduleResolution": "node"
},
"exclude": []
}
在 package.json 添加
...
{
"scripts": {
"build:api": "node ../bin/cli.js api -o ./swagger/api -r http://cloud-his-server.dev.medway.cloud && npm run build",
"build:enum": "node ../bin/cli.js enum -o ./swagger/enum -r http://cloud-his-server.dev.medway.cloud && npm run build",
"build": "tsc -p ./swagger"
}
}
...