Skip to content

代码生成

js
import type { GenerateServiceProps } from 'openapi-ts-request'
import type { APIDataType } from 'openapi-ts-request/dist/generator/type'
import { genDefaultFunctionName, resolveFunctionName, stripDot } from 'openapi-ts-request/dist/generator/util'

export default [
  {
    schemaPath: 'http://localhost:5001/swagger/v1/swagger.json', // openapi文件
    serversPath: './src/apis/walle', // 接口存放路径
    requestLibPath: '@/utils/request/index.ts',
    isGenJavaScript: true,
    hook: {
      customFunctionName(data: APIDataType, prefix: string) {
        if (data.operationId) return resolveFunctionName(stripDot(data.operationId), data.method)
        return data.method + genDefaultFunctionName(data.path, prefix)
      },
    },
    includeTags: ["SysApiRoute", "SysApiUser", "SysApiUserRoute"]
  },
] as GenerateServiceProps[]

上次更新时间:

最近更新