Explorar o código

fix: openapi-ts-request 生成的代码,options 类型定义不对

Utopia hai 6 meses
pai
achega
234dc829c9
Modificáronse 4 ficheiros con 9 adicións e 6 borrados
  1. 2 2
      openapi-ts-request.config.ts
  2. 3 0
      src/http/types.ts
  3. 2 2
      src/service/info.ts
  4. 2 2
      src/service/listAll.ts

+ 2 - 2
openapi-ts-request.config.ts

@@ -5,8 +5,8 @@ export default defineConfig([
     describe: 'unibest-openapi-test',
     schemaPath: 'https://ukw0y1.laf.run/unibest-opapi-test.json',
     serversPath: './src/service',
-    requestLibPath: `import request from '@/http/vue-query';\n import { CustomRequestOptions } from '@/http/types';`,
-    requestOptionsType: 'CustomRequestOptions',
+    requestLibPath: `import request from '@/http/vue-query';\n import { CustomRequestOptions_ } from '@/http/types';`,
+    requestOptionsType: 'CustomRequestOptions_',
     isGenReactQuery: false,
     reactQueryMode: 'vue',
     isGenJavaScript: false,

+ 3 - 0
src/http/types.ts

@@ -7,6 +7,9 @@ export type CustomRequestOptions = UniApp.RequestOptions & {
   hideErrorToast?: boolean
 } & IUniUploadFileOptions // 添加uni.uploadFile参数类型
 
+/** 主要提供给 openapi-ts-request 生成的代码使用 */
+export type CustomRequestOptions_ = Omit<CustomRequestOptions, 'url'>
+
 export interface HttpRequestResult<T> {
   promise: Promise<T>
   requestTask: UniApp.RequestTask

+ 2 - 2
src/service/info.ts

@@ -1,12 +1,12 @@
 /* eslint-disable */
 // @ts-ignore
 import request from '@/http/vue-query';
-import { CustomRequestOptions } from '@/http/types';
+import { CustomRequestOptions_ } from '@/http/types';
 
 import * as API from './types';
 
 /** 用户信息 GET /user/info */
-export function infoUsingGet({ options }: { options?: CustomRequestOptions }) {
+export function infoUsingGet({ options }: { options?: CustomRequestOptions_ }) {
   return request<API.InfoUsingGetResponse>('/user/info', {
     method: 'GET',
     ...(options || {}),

+ 2 - 2
src/service/listAll.ts

@@ -1,7 +1,7 @@
 /* eslint-disable */
 // @ts-ignore
 import request from '@/http/vue-query';
-import { CustomRequestOptions } from '@/http/types';
+import { CustomRequestOptions_ } from '@/http/types';
 
 import * as API from './types';
 
@@ -9,7 +9,7 @@ import * as API from './types';
 export function listAllUsingGet({
   options,
 }: {
-  options?: CustomRequestOptions;
+  options?: CustomRequestOptions_;
 }) {
   return request<API.ListAllUsingGetResponse>('/user/listAll', {
     method: 'GET',