templates/ytt.config.ts
2022-08-04 15:54:02 +08:00

36 lines
1.1 KiB
TypeScript

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}`)
},
},
],
},
],
},
])