本插件是根据 pontx 结合 react 请求库 swr 生成react API请求服务,方便大家使用。
-
执行
npm install pontx-react-ts -D -
在
pontx-config.json中新增"generate":"pontx-react-ts"
{
"outDir": "../src/pontx-services",
"plugins": {
// pontx built-in plugin or your custom plugin
"generate":"pontx-react-ts"
},
"origins": [{
// Pontx support mulitple origins in one project.
// Pontx support OAS2、OAS3 origin by default. You can contribute Pontx Parse Plugin to support other type of origin.
"name": "name1",
"url": "myhost/v2/api-docs.json"
}, {
"name": "name2",
"envs": {
"daily": "my-daily-host/v2/api-docs.json",
"pre": "my-pre-host/v2/api-docs.json",
"prod": "myhost/v2/api-docs.json",
},
"env": "prod"
}]
}- 在根目录 新增
utils/service.ts可参考当前插件目录中./template/service.ts