feat: 添加ytt

This commit is contained in:
NICE CODE BY DEV 2022-08-04 15:54:02 +08:00
parent 8c399e6aaf
commit b86253a6ee
2 changed files with 37 additions and 0 deletions

View File

@ -73,6 +73,7 @@
"postcss-px2rem": "^0.3.0",
"prettier": "^1.19.1",
"typescript": "^4.1.3",
"yapi-to-typescript": "^3.34.1",
"yorkie": "^2.0.0"
}
}

36
ytt.config.ts Normal file
View File

@ -0,0 +1,36 @@
import { defineConfig } from 'yapi-to-typescript'
export default defineConfig([
{
serverUrl: 'http://yapi.jzxer.cn',
typesOnly: false,
target: 'typescript',
reactHooks: {
enabled: false,
},
prodEnvName: 'production',
outputFilePath: 'src/api/index.ts',
requestFunctionFilePath: 'src/utils/request.ts',
dataKey: 'data',
projects: [
{
token: '',
categories: [
{
id: 0,
getRequestFunctionName(interfaceInfo, changeCase) {
// 以接口全路径生成请求函数名
return changeCase.camelCase(interfaceInfo.path)
// 若生成的请求函数名存在语法关键词报错、或想通过某个关键词触发 IDE 自动引入提示,可考虑加前缀,如:
// return changeCase.camelCase(`api_${interfaceInfo.path}`)
// 若生成的请求函数名有重复报错,可考虑将接口请求方式纳入生成条件,如:
// return changeCase.camelCase(`${interfaceInfo.method}_${interfaceInfo.path}`)
},
},
],
},
],
},
])