Skip to content

Commit 46eccd4

Browse files
committed
fix: remove unusing parameters in swr plugin
1 parent 5c53c2c commit 46eccd4

File tree

15 files changed

+213
-181
lines changed

15 files changed

+213
-181
lines changed

examples/openapi-ts-swr/src/client/swr.gen.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import type {
4444
UploadFileData,
4545
} from './types.gen';
4646

47-
/* eslint-disable @typescript-eslint/no-unused-vars */
4847
/**
4948
* Add a new pet to the store.
5049
*
@@ -227,9 +226,7 @@ export const uploadFileMutation = (options?: Options<UploadFileData>) => ({
227226
: ['/pet/{petId}/uploadImage'],
228227
});
229228

230-
export const getInventoryKey = (options?: Options<GetInventoryData>) => [
231-
'/store/inventory',
232-
];
229+
export const getInventoryKey = () => ['/store/inventory'];
233230

234231
/**
235232
* Returns pet inventories by status.
@@ -241,7 +238,7 @@ export const getInventoryOptions = (options?: Options<GetInventoryData>) => ({
241238
const { data } = await getInventory({ ...options, throwOnError: true });
242239
return data;
243240
},
244-
key: getInventoryKey(options),
241+
key: getInventoryKey(),
245242
});
246243

247244
/**
@@ -380,9 +377,7 @@ export const loginUserOptions = (options?: Options<LoginUserData>) => ({
380377
key: loginUserKey(options),
381378
});
382379

383-
export const logoutUserKey = (options?: Options<LogoutUserData>) => [
384-
'/user/logout',
385-
];
380+
export const logoutUserKey = () => ['/user/logout'];
386381

387382
/**
388383
* Logs out current logged in user session.
@@ -394,7 +389,7 @@ export const logoutUserOptions = (options?: Options<LogoutUserData>) => ({
394389
const { data } = await logoutUser({ ...options, throwOnError: true });
395390
return data;
396391
},
397-
key: logoutUserKey(options),
392+
key: logoutUserKey(),
398393
});
399394

400395
/**

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/swr/asClass/swr.gen.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import type { FooBarPostData, FooBarPutData, FooPostData, FooPutData, GetFooBarD
66
/* eslint-disable @typescript-eslint/no-unused-vars */
77
;
88

9-
export const getFooKey = (options?: Options<GetFooData>) => ["/foo"];
9+
export const getFooKey = () => ["/foo"];
1010

1111
export const getFooOptions = (options?: Options<GetFooData>) => ({
12-
key: getFooKey(options),
12+
key: getFooKey(),
1313
fetcher: async () => {
1414
const { data } = await FooBazService.getFoo({ ...options, throwOnError: true });
1515
return data;
@@ -44,10 +44,10 @@ export const fooPutMutation = (options?: Options<FooPutData>) => ({
4444
}
4545
});
4646

47-
export const getFooBarKey = (options?: Options<GetFooBarData>) => ["/foo/bar"];
47+
export const getFooBarKey = () => ["/foo/bar"];
4848

4949
export const getFooBarOptions = (options?: Options<GetFooBarData>) => ({
50-
key: getFooBarKey(options),
50+
key: getFooBarKey(),
5151
fetcher: async () => {
5252
const { data } = await BarBazService.getFooBar({ ...options, throwOnError: true });
5353
return data;

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/swr/axios/swr.gen.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import type { CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData
66
/* eslint-disable @typescript-eslint/no-unused-vars */
77
;
88

9-
export const serviceWithEmptyTagKey = (options?: Options<ServiceWithEmptyTagData>) => ["/api/v{api-version}/no+tag"];
9+
export const serviceWithEmptyTagKey = () => ["/api/v{api-version}/no+tag"];
1010

1111
export const serviceWithEmptyTagOptions = (options?: Options<ServiceWithEmptyTagData>) => ({
12-
key: serviceWithEmptyTagKey(options),
12+
key: serviceWithEmptyTagKey(),
1313
fetcher: async () => {
1414
const { data } = await serviceWithEmptyTag({ ...options, throwOnError: true });
1515
return data;
@@ -58,10 +58,10 @@ export const deleteCallWithoutParametersAndResponseMutation = (options?: Options
5858
}
5959
});
6060

61-
export const getCallWithoutParametersAndResponseKey = (options?: Options<GetCallWithoutParametersAndResponseData>) => ["/api/v{api-version}/simple"];
61+
export const getCallWithoutParametersAndResponseKey = () => ["/api/v{api-version}/simple"];
6262

6363
export const getCallWithoutParametersAndResponseOptions = (options?: Options<GetCallWithoutParametersAndResponseData>) => ({
64-
key: getCallWithoutParametersAndResponseKey(options),
64+
key: getCallWithoutParametersAndResponseKey(),
6565
fetcher: async () => {
6666
const { data } = await getCallWithoutParametersAndResponse({ ...options, throwOnError: true });
6767
return data;
@@ -204,10 +204,10 @@ export const duplicateNameMutation = (options?: Options<DuplicateNameData>) => (
204204
}
205205
});
206206

207-
export const duplicateName2Key = (options?: Options<DuplicateName2Data>) => ["/api/v{api-version}/duplicate"];
207+
export const duplicateName2Key = () => ["/api/v{api-version}/duplicate"];
208208

209209
export const duplicateName2Options = (options?: Options<DuplicateName2Data>) => ({
210-
key: duplicateName2Key(options),
210+
key: duplicateName2Key(),
211211
fetcher: async () => {
212212
const { data } = await duplicateName2({ ...options, throwOnError: true });
213213
return data;
@@ -242,50 +242,50 @@ export const duplicateName4Mutation = (options?: Options<DuplicateName4Data>) =>
242242
}
243243
});
244244

245-
export const callWithNoContentResponseKey = (options?: Options<CallWithNoContentResponseData>) => ["/api/v{api-version}/no-content"];
245+
export const callWithNoContentResponseKey = () => ["/api/v{api-version}/no-content"];
246246

247247
export const callWithNoContentResponseOptions = (options?: Options<CallWithNoContentResponseData>) => ({
248-
key: callWithNoContentResponseKey(options),
248+
key: callWithNoContentResponseKey(),
249249
fetcher: async () => {
250250
const { data } = await callWithNoContentResponse({ ...options, throwOnError: true });
251251
return data;
252252
}
253253
});
254254

255-
export const callWithResponseAndNoContentResponseKey = (options?: Options<CallWithResponseAndNoContentResponseData>) => ["/api/v{api-version}/multiple-tags/response-and-no-content"];
255+
export const callWithResponseAndNoContentResponseKey = () => ["/api/v{api-version}/multiple-tags/response-and-no-content"];
256256

257257
export const callWithResponseAndNoContentResponseOptions = (options?: Options<CallWithResponseAndNoContentResponseData>) => ({
258-
key: callWithResponseAndNoContentResponseKey(options),
258+
key: callWithResponseAndNoContentResponseKey(),
259259
fetcher: async () => {
260260
const { data } = await callWithResponseAndNoContentResponse({ ...options, throwOnError: true });
261261
return data;
262262
}
263263
});
264264

265-
export const dummyAKey = (options?: Options<DummyAData>) => ["/api/v{api-version}/multiple-tags/a"];
265+
export const dummyAKey = () => ["/api/v{api-version}/multiple-tags/a"];
266266

267267
export const dummyAOptions = (options?: Options<DummyAData>) => ({
268-
key: dummyAKey(options),
268+
key: dummyAKey(),
269269
fetcher: async () => {
270270
const { data } = await dummyA({ ...options, throwOnError: true });
271271
return data;
272272
}
273273
});
274274

275-
export const dummyBKey = (options?: Options<DummyBData>) => ["/api/v{api-version}/multiple-tags/b"];
275+
export const dummyBKey = () => ["/api/v{api-version}/multiple-tags/b"];
276276

277277
export const dummyBOptions = (options?: Options<DummyBData>) => ({
278-
key: dummyBKey(options),
278+
key: dummyBKey(),
279279
fetcher: async () => {
280280
const { data } = await dummyB({ ...options, throwOnError: true });
281281
return data;
282282
}
283283
});
284284

285-
export const callWithResponseKey = (options?: Options<CallWithResponseData>) => ["/api/v{api-version}/response"];
285+
export const callWithResponseKey = () => ["/api/v{api-version}/response"];
286286

287287
export const callWithResponseOptions = (options?: Options<CallWithResponseData>) => ({
288-
key: callWithResponseKey(options),
288+
key: callWithResponseKey(),
289289
fetcher: async () => {
290290
const { data } = await callWithResponse({ ...options, throwOnError: true });
291291
return data;

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/swr/fetch/swr.gen.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import type { CallToTestOrderOfParamsData, CallWithDefaultOptionalParametersData
66
/* eslint-disable @typescript-eslint/no-unused-vars */
77
;
88

9-
export const serviceWithEmptyTagKey = (options?: Options<ServiceWithEmptyTagData>) => ["/api/v{api-version}/no+tag"];
9+
export const serviceWithEmptyTagKey = () => ["/api/v{api-version}/no+tag"];
1010

1111
export const serviceWithEmptyTagOptions = (options?: Options<ServiceWithEmptyTagData>) => ({
12-
key: serviceWithEmptyTagKey(options),
12+
key: serviceWithEmptyTagKey(),
1313
fetcher: async () => {
1414
const { data } = await serviceWithEmptyTag({ ...options, throwOnError: true });
1515
return data;
@@ -58,10 +58,10 @@ export const deleteCallWithoutParametersAndResponseMutation = (options?: Options
5858
}
5959
});
6060

61-
export const getCallWithoutParametersAndResponseKey = (options?: Options<GetCallWithoutParametersAndResponseData>) => ["/api/v{api-version}/simple"];
61+
export const getCallWithoutParametersAndResponseKey = () => ["/api/v{api-version}/simple"];
6262

6363
export const getCallWithoutParametersAndResponseOptions = (options?: Options<GetCallWithoutParametersAndResponseData>) => ({
64-
key: getCallWithoutParametersAndResponseKey(options),
64+
key: getCallWithoutParametersAndResponseKey(),
6565
fetcher: async () => {
6666
const { data } = await getCallWithoutParametersAndResponse({ ...options, throwOnError: true });
6767
return data;
@@ -204,10 +204,10 @@ export const duplicateNameMutation = (options?: Options<DuplicateNameData>) => (
204204
}
205205
});
206206

207-
export const duplicateName2Key = (options?: Options<DuplicateName2Data>) => ["/api/v{api-version}/duplicate"];
207+
export const duplicateName2Key = () => ["/api/v{api-version}/duplicate"];
208208

209209
export const duplicateName2Options = (options?: Options<DuplicateName2Data>) => ({
210-
key: duplicateName2Key(options),
210+
key: duplicateName2Key(),
211211
fetcher: async () => {
212212
const { data } = await duplicateName2({ ...options, throwOnError: true });
213213
return data;
@@ -242,50 +242,50 @@ export const duplicateName4Mutation = (options?: Options<DuplicateName4Data>) =>
242242
}
243243
});
244244

245-
export const callWithNoContentResponseKey = (options?: Options<CallWithNoContentResponseData>) => ["/api/v{api-version}/no-content"];
245+
export const callWithNoContentResponseKey = () => ["/api/v{api-version}/no-content"];
246246

247247
export const callWithNoContentResponseOptions = (options?: Options<CallWithNoContentResponseData>) => ({
248-
key: callWithNoContentResponseKey(options),
248+
key: callWithNoContentResponseKey(),
249249
fetcher: async () => {
250250
const { data } = await callWithNoContentResponse({ ...options, throwOnError: true });
251251
return data;
252252
}
253253
});
254254

255-
export const callWithResponseAndNoContentResponseKey = (options?: Options<CallWithResponseAndNoContentResponseData>) => ["/api/v{api-version}/multiple-tags/response-and-no-content"];
255+
export const callWithResponseAndNoContentResponseKey = () => ["/api/v{api-version}/multiple-tags/response-and-no-content"];
256256

257257
export const callWithResponseAndNoContentResponseOptions = (options?: Options<CallWithResponseAndNoContentResponseData>) => ({
258-
key: callWithResponseAndNoContentResponseKey(options),
258+
key: callWithResponseAndNoContentResponseKey(),
259259
fetcher: async () => {
260260
const { data } = await callWithResponseAndNoContentResponse({ ...options, throwOnError: true });
261261
return data;
262262
}
263263
});
264264

265-
export const dummyAKey = (options?: Options<DummyAData>) => ["/api/v{api-version}/multiple-tags/a"];
265+
export const dummyAKey = () => ["/api/v{api-version}/multiple-tags/a"];
266266

267267
export const dummyAOptions = (options?: Options<DummyAData>) => ({
268-
key: dummyAKey(options),
268+
key: dummyAKey(),
269269
fetcher: async () => {
270270
const { data } = await dummyA({ ...options, throwOnError: true });
271271
return data;
272272
}
273273
});
274274

275-
export const dummyBKey = (options?: Options<DummyBData>) => ["/api/v{api-version}/multiple-tags/b"];
275+
export const dummyBKey = () => ["/api/v{api-version}/multiple-tags/b"];
276276

277277
export const dummyBOptions = (options?: Options<DummyBData>) => ({
278-
key: dummyBKey(options),
278+
key: dummyBKey(),
279279
fetcher: async () => {
280280
const { data } = await dummyB({ ...options, throwOnError: true });
281281
return data;
282282
}
283283
});
284284

285-
export const callWithResponseKey = (options?: Options<CallWithResponseData>) => ["/api/v{api-version}/response"];
285+
export const callWithResponseKey = () => ["/api/v{api-version}/response"];
286286

287287
export const callWithResponseOptions = (options?: Options<CallWithResponseData>) => ({
288-
key: callWithResponseKey(options),
288+
key: callWithResponseKey(),
289289
fetcher: async () => {
290290
const { data } = await callWithResponse({ ...options, throwOnError: true });
291291
return data;

packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/swr/asClass/swr.gen.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import type { FooBarPostData, FooBarPutData, FooPostData, FooPutData, GetFooBarD
66
/* eslint-disable @typescript-eslint/no-unused-vars */
77
;
88

9-
export const getFooKey = (options?: Options<GetFooData>) => ["/foo"];
9+
export const getFooKey = () => ["/foo"];
1010

1111
export const getFooOptions = (options?: Options<GetFooData>) => ({
12-
key: getFooKey(options),
12+
key: getFooKey(),
1313
fetcher: async () => {
1414
const { data } = await FooBazService.getFoo({ ...options, throwOnError: true });
1515
return data;
@@ -44,10 +44,10 @@ export const fooPutMutation = (options?: Options<FooPutData>) => ({
4444
}
4545
});
4646

47-
export const getFooBarKey = (options?: Options<GetFooBarData>) => ["/foo/bar"];
47+
export const getFooBarKey = () => ["/foo/bar"];
4848

4949
export const getFooBarOptions = (options?: Options<GetFooBarData>) => ({
50-
key: getFooBarKey(options),
50+
key: getFooBarKey(),
5151
fetcher: async () => {
5252
const { data } = await BarBazService.getFooBar({ ...options, throwOnError: true });
5353
return data;

0 commit comments

Comments
 (0)