jr-codegen
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

生成 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"
  }
}
...

Package Sidebar

Install

npm i jr-codegen

Weekly Downloads

5

Version

1.1.5

License

MIT

Unpacked Size

201 kB

Total Files

81

Last publish

Collaborators

  • fusy