auto-request
Version:
通过Yapi JSON Schema生成接口Axios或Taro接口
28 lines (24 loc) • 742 B
text/typescript
/**
* 开发模式测试 - open
* 从源码导入
*/
import { autoRequest } from '@/index';
import path from 'path';
import openApi from '@/../example/open/swagger.json';
const { openConfig, getConfig } = require('./../base/configs');
const generatorApi = (source, api, log, snapshots) => {
const config = getConfig(openConfig, {
snapshotsPath: snapshots,
});
autoRequest(JSON.stringify(source) as any, api, config as any)
.then(({ write, template }: any) => {
write();
})
.catch((err) => console.log(err));
};
generatorApi(
openApi,
path.join(__dirname, './../../example/open/api/'),
path.join(__dirname, './../../example/open/logs/'),
path.join(__dirname, './../../example/open/snapshots.md')
);