Skip to content

miserylee/koact-doc-to-definition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koact-doc-to-definition

NPM version

怎么使用?

使用npmyarn全局安装koact-doc-to-definition

在项目根目录下创建配置文件koact-api-generator.config.json

{
  "url": "http://localhost:3000",
  "destination": "test/apis/axios",
  "docSecret": "123456",
  "target": "axios",
  "pattern": [
    "**",
    "!/ms/*"
  ]
}

注意:destination配置是相对于命令执行目录的地址

// 配置文件数据结构
export interface IOptions {
  url: string; // 使用了`koact`作为路由组件的`koa`服务器地址;
  destination: string; // 希望API文件存放的文件夹地址;
  docSecret?: string; // koact doc密钥(如果服务端设置了);
  target?: 'axios' | 'msio'; // 要生成的接口文件类型;
  pattern?: string | string[]; // 接口过滤规则
}

接口过滤规则的配置参考multimatch

在项目目录下执行koact-doc-to-definition指令即可。

可使用--config [config-file-path]来指定配置文件的地址,默认为koact-api-generator.config.json

多个服务出口的情况

可以将koact-api-generator.config.json配置为IOptions[]的格式即可。

About

Transform koact api document to typescript file for web-front-end project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published