Skip to content

Commit 7dacec3

Browse files
bayasdevmarkerikson
authored andcommitted
Add "encodeParams" tests
1 parent 1d60b72 commit 7dacec3

File tree

3 files changed

+196
-36
lines changed

3 files changed

+196
-36
lines changed

packages/rtk-query-codegen-openapi/test/__snapshots__/cli.test.ts.snap

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,20 @@ const injectedRtkApi = api.injectEndpoints({
1111
query: (queryArg) => ({ url: \`/pet\`, method: 'POST', body: queryArg.pet }),
1212
}),
1313
findPetsByStatus: build.query<FindPetsByStatusApiResponse, FindPetsByStatusApiArg>({
14-
query: (queryArg) => ({ url: \`/pet/findByStatus\`, params: { status: queryArg.status } }),
14+
query: (queryArg) => ({
15+
url: \`/pet/findByStatus\`,
16+
params: {
17+
status: queryArg.status,
18+
},
19+
}),
1520
}),
1621
findPetsByTags: build.query<FindPetsByTagsApiResponse, FindPetsByTagsApiArg>({
17-
query: (queryArg) => ({ url: \`/pet/findByTags\`, params: { tags: queryArg.tags } }),
22+
query: (queryArg) => ({
23+
url: \`/pet/findByTags\`,
24+
params: {
25+
tags: queryArg.tags,
26+
},
27+
}),
1828
}),
1929
getPetById: build.query<GetPetByIdApiResponse, GetPetByIdApiArg>({
2030
query: (queryArg) => ({ url: \`/pet/\${queryArg.petId}\` }),
@@ -23,18 +33,29 @@ const injectedRtkApi = api.injectEndpoints({
2333
query: (queryArg) => ({
2434
url: \`/pet/\${queryArg.petId}\`,
2535
method: 'POST',
26-
params: { name: queryArg.name, status: queryArg.status },
36+
params: {
37+
name: queryArg.name,
38+
status: queryArg.status,
39+
},
2740
}),
2841
}),
2942
deletePet: build.mutation<DeletePetApiResponse, DeletePetApiArg>({
30-
query: (queryArg) => ({ url: \`/pet/\${queryArg.petId}\`, method: 'DELETE', headers: { api_key: queryArg.apiKey } }),
43+
query: (queryArg) => ({
44+
url: \`/pet/\${queryArg.petId}\`,
45+
method: 'DELETE',
46+
headers: {
47+
api_key: queryArg.apiKey,
48+
},
49+
}),
3150
}),
3251
uploadFile: build.mutation<UploadFileApiResponse, UploadFileApiArg>({
3352
query: (queryArg) => ({
3453
url: \`/pet/\${queryArg.petId}/uploadImage\`,
3554
method: 'POST',
3655
body: queryArg.body,
37-
params: { additionalMetadata: queryArg.additionalMetadata },
56+
params: {
57+
additionalMetadata: queryArg.additionalMetadata,
58+
},
3859
}),
3960
}),
4061
getInventory: build.query<GetInventoryApiResponse, GetInventoryApiArg>({
@@ -58,7 +79,10 @@ const injectedRtkApi = api.injectEndpoints({
5879
loginUser: build.query<LoginUserApiResponse, LoginUserApiArg>({
5980
query: (queryArg) => ({
6081
url: \`/user/login\`,
61-
params: { username: queryArg.username, password: queryArg.password },
82+
params: {
83+
username: queryArg.username,
84+
password: queryArg.password,
85+
},
6286
}),
6387
}),
6488
logoutUser: build.query<LogoutUserApiResponse, LogoutUserApiArg>({
@@ -234,10 +258,20 @@ const injectedRtkApi = api.injectEndpoints({
234258
query: (queryArg) => ({ url: \`/pet\`, method: 'POST', body: queryArg.pet }),
235259
}),
236260
findPetsByStatus: build.query<FindPetsByStatusApiResponse, FindPetsByStatusApiArg>({
237-
query: (queryArg) => ({ url: \`/pet/findByStatus\`, params: { status: queryArg.status } }),
261+
query: (queryArg) => ({
262+
url: \`/pet/findByStatus\`,
263+
params: {
264+
status: queryArg.status,
265+
},
266+
}),
238267
}),
239268
findPetsByTags: build.query<FindPetsByTagsApiResponse, FindPetsByTagsApiArg>({
240-
query: (queryArg) => ({ url: \`/pet/findByTags\`, params: { tags: queryArg.tags } }),
269+
query: (queryArg) => ({
270+
url: \`/pet/findByTags\`,
271+
params: {
272+
tags: queryArg.tags,
273+
},
274+
}),
241275
}),
242276
getPetById: build.query<GetPetByIdApiResponse, GetPetByIdApiArg>({
243277
query: (queryArg) => ({ url: \`/pet/\${queryArg.petId}\` }),
@@ -246,18 +280,29 @@ const injectedRtkApi = api.injectEndpoints({
246280
query: (queryArg) => ({
247281
url: \`/pet/\${queryArg.petId}\`,
248282
method: 'POST',
249-
params: { name: queryArg.name, status: queryArg.status },
283+
params: {
284+
name: queryArg.name,
285+
status: queryArg.status,
286+
},
250287
}),
251288
}),
252289
deletePet: build.mutation<DeletePetApiResponse, DeletePetApiArg>({
253-
query: (queryArg) => ({ url: \`/pet/\${queryArg.petId}\`, method: 'DELETE', headers: { api_key: queryArg.apiKey } }),
290+
query: (queryArg) => ({
291+
url: \`/pet/\${queryArg.petId}\`,
292+
method: 'DELETE',
293+
headers: {
294+
api_key: queryArg.apiKey,
295+
},
296+
}),
254297
}),
255298
uploadFile: build.mutation<UploadFileApiResponse, UploadFileApiArg>({
256299
query: (queryArg) => ({
257300
url: \`/pet/\${queryArg.petId}/uploadImage\`,
258301
method: 'POST',
259302
body: queryArg.body,
260-
params: { additionalMetadata: queryArg.additionalMetadata },
303+
params: {
304+
additionalMetadata: queryArg.additionalMetadata,
305+
},
261306
}),
262307
}),
263308
getInventory: build.query<GetInventoryApiResponse, GetInventoryApiArg>({
@@ -281,7 +326,10 @@ const injectedRtkApi = api.injectEndpoints({
281326
loginUser: build.query<LoginUserApiResponse, LoginUserApiArg>({
282327
query: (queryArg) => ({
283328
url: \`/user/login\`,
284-
params: { username: queryArg.username, password: queryArg.password },
329+
params: {
330+
username: queryArg.username,
331+
password: queryArg.password,
332+
},
285333
}),
286334
}),
287335
logoutUser: build.query<LogoutUserApiResponse, LogoutUserApiArg>({

0 commit comments

Comments
 (0)