Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/miserylee/koact-doc-to-definition
Transform koact api document to typescript file for web-front-end project.
https://github.com/miserylee/koact-doc-to-definition
Last synced: 6 days ago
JSON representation
Transform koact api document to typescript file for web-front-end project.
- Host: GitHub
- URL: https://github.com/miserylee/koact-doc-to-definition
- Owner: miserylee
- Created: 2020-01-08T09:42:30.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T15:45:49.000Z (about 2 years ago)
- Last Synced: 2024-11-01T00:12:39.688Z (about 2 months ago)
- Language: TypeScript
- Size: 373 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# koact-doc-to-definition
## ![NPM version](https://img.shields.io/npm/v/koact-doc-to-definition.svg?style=flat)
# 怎么使用?
使用`npm`或`yarn`全局安装`koact-doc-to-definition`
在项目根目录下创建配置文件`koact-api-generator.config.json`:
```json
{
"url": "http://localhost:3000",
"destination": "test/apis/axios",
"docSecret": "123456",
"target": "axios",
"pattern": [
"**",
"!/ms/*"
]
}
```**注意:`destination`配置是相对于命令执行目录的地址**
```typescript
// 配置文件数据结构
export interface IOptions {
url: string; // 使用了`koact`作为路由组件的`koa`服务器地址;
destination: string; // 希望API文件存放的文件夹地址;
docSecret?: string; // koact doc密钥(如果服务端设置了);
target?: 'axios' | 'msio'; // 要生成的接口文件类型;
pattern?: string | string[]; // 接口过滤规则
}
```接口过滤规则的配置参考[multimatch](https://github.com/sindresorhus/multimatch)。
在项目目录下执行`koact-doc-to-definition`指令即可。
可使用`--config [config-file-path]`来指定配置文件的地址,默认为`koact-api-generator.config.json`。
# 多个服务出口的情况
可以将`koact-api-generator.config.json`配置为`IOptions[]`的格式即可。