-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.config.ts
More file actions
23 lines (22 loc) · 812 Bytes
/
api.config.ts
File metadata and controls
23 lines (22 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { defineConfig } from '@jawilx/gen-api'
export default defineConfig({
apiList: [
{
swaggerUrl: '',
outputDir: '/src/api',
urlPrefix: '',
enable: true,
ignore: /\/test\//,
},
],
httpTpl: `import type { UseFetchOptions } from '@vueuse/core'`,
apiBody: ({ url, method, summary, name, formDataStr, outputInterface, pstr1, pstr2 }) => {
pstr1 = `${pstr1?.replace(/(data\??: )/, '$1MaybeRef<')}>`
url = url.replace(/\{data/, '{unref(data)')
return `
/** ${summary || '无注释'} */
export function ${name}(${pstr1}, useFetchOptions?: UseFetchOptions): UseFetchReturn<${outputInterface}['data']> {
return use${method}${formDataStr}<${outputInterface}>(\`${url}\`, ${pstr2}, useFetchOptions)
}`
},
})