Skip to content

Commit

Permalink
Handle updated params formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Aug 30, 2024
1 parent 1f6c72e commit 3585e82
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,9 @@ const injectedRtkApi = api.injectEndpoints({
>({
query: (queryArg) => ({
url: \`/pet/findByStatus\`,
params: { status: queryArg.status },
params: {
status: queryArg.status,
},
}),
}),
findPetsByTags: build.query<
Expand Down Expand Up @@ -1123,7 +1125,8 @@ export type DeleteOrderApiArg = {
/** ID of the order that needs to be deleted */
orderId: number;
};
export type CreateUserApiResponse = unknown;
export type CreateUserApiResponse =
/** status default successful operation */ User;
export type CreateUserApiArg = {
/** Created user object */
user: User;
Expand Down Expand Up @@ -1170,6 +1173,7 @@ export type Pet = {
category?: Category | undefined;
photoUrls: string[];
tags?: Tag[] | undefined;
/** pet status in the store */
status?: ("available" | "pending" | "sold") | undefined;
};
export type ApiResponse = {
Expand All @@ -1182,6 +1186,7 @@ export type Order = {
petId?: number | undefined;
quantity?: number | undefined;
shipDate?: string | undefined;
/** Order Status */
status?: ("placed" | "approved" | "delivered") | undefined;
complete?: boolean | undefined;
};
Expand All @@ -1193,6 +1198,7 @@ export type User = {
email?: string | undefined;
password?: string | undefined;
phone?: string | undefined;
/** User Status */
userStatus?: number | undefined;
};
"
Expand Down Expand Up @@ -1240,22 +1246,28 @@ const injectedRtkApi = api.injectEndpoints({
query: (queryArg) => ({
url: \`/pet/\${queryArg.petId}\`,
method: "POST",
params: { name: queryArg.name },
params: {
name: queryArg.name,
},
}),
}),
deletePet: build.mutation<DeletePetApiResponse, DeletePetApiArg>({
query: (queryArg) => ({
url: \`/pet/\${queryArg.petId}\`,
method: "DELETE",
headers: { api_key: queryArg.apiKey },
headers: {
api_key: queryArg.apiKey,
},
}),
}),
uploadFile: build.mutation<UploadFileApiResponse, UploadFileApiArg>({
query: (queryArg) => ({
url: \`/pet/\${queryArg.petId}/uploadImage\`,
method: "POST",
body: queryArg.body,
params: { additionalMetadata: queryArg.additionalMetadata },
params: {
additionalMetadata: queryArg.additionalMetadata,
},
}),
}),
getInventory: build.query<GetInventoryApiResponse, GetInventoryApiArg>({
Expand Down Expand Up @@ -1297,7 +1309,9 @@ const injectedRtkApi = api.injectEndpoints({
loginUser: build.query<LoginUserApiResponse, LoginUserApiArg>({
query: (queryArg) => ({
url: \`/user/login\`,
params: { username: queryArg.username },
params: {
username: queryArg.username,
},
}),
}),
logoutUser: build.query<LogoutUserApiResponse, LogoutUserApiArg>({
Expand Down Expand Up @@ -1390,7 +1404,8 @@ export type DeleteOrderApiArg = {
/** ID of the order that needs to be deleted */
orderId: number;
};
export type CreateUserApiResponse = unknown;
export type CreateUserApiResponse =
/** status default successful operation */ User;
export type CreateUserApiArg = {
/** Created user object */
user: User;
Expand Down Expand Up @@ -1440,6 +1455,7 @@ export type Pet = {
category?: Category | undefined;
photoUrls: string[];
tags?: Tag[] | undefined;
/** pet status in the store */
status?: ("available" | "pending" | "sold") | undefined;
};
export type ApiResponse = {
Expand All @@ -1452,6 +1468,7 @@ export type Order = {
petId?: number | undefined;
quantity?: number | undefined;
shipDate?: string | undefined;
/** Order Status */
status?: ("placed" | "approved" | "delivered") | undefined;
complete?: boolean | undefined;
};
Expand All @@ -1463,6 +1480,7 @@ export type User = {
email?: string | undefined;
password?: string | undefined;
phone?: string | undefined;
/** User Status */
userStatus?: number | undefined;
};
"
Expand Down Expand Up @@ -1494,7 +1512,9 @@ const injectedRtkApi = api.injectEndpoints({
>({
query: (queryArg) => ({
url: \`/pet/findByStatus\`,
params: { status: queryArg.status },
params: {
status: queryArg.status,
},
}),
}),
findPetsByTags: build.query<
Expand All @@ -1503,7 +1523,9 @@ const injectedRtkApi = api.injectEndpoints({
>({
query: (queryArg) => ({
url: \`/pet/findByTags\`,
params: { tags: queryArg.tags },
params: {
tags: queryArg.tags,
},
}),
}),
getPetById: build.query<GetPetByIdApiResponse, GetPetByIdApiArg>({
Expand All @@ -1516,7 +1538,10 @@ const injectedRtkApi = api.injectEndpoints({
query: (queryArg) => ({
url: \`/pet/\${queryArg.petId}\`,
method: "POST",
params: { name: queryArg.name, status: queryArg.status },
params: {
name: queryArg.name,
status: queryArg.status,
},
}),
}),
deletePet: build.mutation<DeletePetApiResponse, DeletePetApiArg>({
Expand All @@ -1530,7 +1555,9 @@ const injectedRtkApi = api.injectEndpoints({
url: \`/pet/\${queryArg.petId}/uploadImage\`,
method: "POST",
body: queryArg.body,
params: { additionalMetadata: queryArg.additionalMetadata },
params: {
additionalMetadata: queryArg.additionalMetadata,
},
}),
}),
getInventory: build.query<GetInventoryApiResponse, GetInventoryApiArg>({
Expand Down Expand Up @@ -1572,7 +1599,10 @@ const injectedRtkApi = api.injectEndpoints({
loginUser: build.query<LoginUserApiResponse, LoginUserApiArg>({
query: (queryArg) => ({
url: \`/user/login\`,
params: { username: queryArg.username, password: queryArg.password },
params: {
username: queryArg.username,
password: queryArg.password,
},
}),
}),
logoutUser: build.query<LogoutUserApiResponse, LogoutUserApiArg>({
Expand Down Expand Up @@ -1672,7 +1702,8 @@ export type DeleteOrderApiArg = {
/** ID of the order that needs to be deleted */
orderId: number;
};
export type CreateUserApiResponse = unknown;
export type CreateUserApiResponse =
/** status default successful operation */ User;
export type CreateUserApiArg = {
/** Created user object */
user: User;
Expand Down Expand Up @@ -1724,6 +1755,7 @@ export type Pet = {
category?: Category | undefined;
photoUrls: string[];
tags?: Tag[] | undefined;
/** pet status in the store */
status?: ("available" | "pending" | "sold") | undefined;
};
export type ApiResponse = {
Expand All @@ -1736,6 +1768,7 @@ export type Order = {
petId?: number | undefined;
quantity?: number | undefined;
shipDate?: string | undefined;
/** Order Status */
status?: ("placed" | "approved" | "delivered") | undefined;
complete?: boolean | undefined;
};
Expand All @@ -1747,6 +1780,7 @@ export type User = {
email?: string | undefined;
password?: string | undefined;
phone?: string | undefined;
/** User Status */
userStatus?: number | undefined;
};
"
Expand Down Expand Up @@ -1794,22 +1828,28 @@ const injectedRtkApi = api.injectEndpoints({
query: (queryArg) => ({
url: \`/pet/\${queryArg.petId}\`,
method: "POST",
params: { name: queryArg.name },
params: {
name: queryArg.name,
},
}),
}),
deletePet: build.mutation<DeletePetApiResponse, DeletePetApiArg>({
query: (queryArg) => ({
url: \`/pet/\${queryArg.petId}\`,
method: "DELETE",
headers: { api_key: queryArg.apiKey },
headers: {
api_key: queryArg.apiKey,
},
}),
}),
uploadFile: build.mutation<UploadFileApiResponse, UploadFileApiArg>({
query: (queryArg) => ({
url: \`/pet/\${queryArg.petId}/uploadImage\`,
method: "POST",
body: queryArg.body,
params: { additionalMetadata: queryArg.additionalMetadata },
params: {
additionalMetadata: queryArg.additionalMetadata,
},
}),
}),
getInventory: build.query<GetInventoryApiResponse, GetInventoryApiArg>({
Expand Down Expand Up @@ -1851,7 +1891,9 @@ const injectedRtkApi = api.injectEndpoints({
loginUser: build.query<LoginUserApiResponse, LoginUserApiArg>({
query: (queryArg) => ({
url: \`/user/login\`,
params: { username: queryArg.username },
params: {
username: queryArg.username,
},
}),
}),
logoutUser: build.query<LogoutUserApiResponse, LogoutUserApiArg>({
Expand Down Expand Up @@ -1944,7 +1986,8 @@ export type DeleteOrderApiArg = {
/** ID of the order that needs to be deleted */
orderId: number;
};
export type CreateUserApiResponse = unknown;
export type CreateUserApiResponse =
/** status default successful operation */ User;
export type CreateUserApiArg = {
/** Created user object */
user: User;
Expand Down Expand Up @@ -1994,6 +2037,7 @@ export type Pet = {
category?: Category | undefined;
photoUrls: string[];
tags?: Tag[] | undefined;
/** pet status in the store */
status?: ("available" | "pending" | "sold") | undefined;
};
export type ApiResponse = {
Expand All @@ -2006,6 +2050,7 @@ export type Order = {
petId?: number | undefined;
quantity?: number | undefined;
shipDate?: string | undefined;
/** Order Status */
status?: ("placed" | "approved" | "delivered") | undefined;
complete?: boolean | undefined;
};
Expand All @@ -2017,6 +2062,7 @@ export type User = {
email?: string | undefined;
password?: string | undefined;
phone?: string | undefined;
/** User Status */
userStatus?: number | undefined;
};
"
Expand Down Expand Up @@ -2048,7 +2094,9 @@ const injectedRtkApi = api.injectEndpoints({
>({
query: (queryArg) => ({
url: \`/pet/findByStatus\`,
params: { status: queryArg.status },
params: {
status: queryArg.status,
},
}),
}),
findPetsByTags: build.query<
Expand All @@ -2067,7 +2115,9 @@ const injectedRtkApi = api.injectEndpoints({
query: (queryArg) => ({
url: \`/pet/\${queryArg.petId}\`,
method: "POST",
params: { status: queryArg.status },
params: {
status: queryArg.status,
},
}),
}),
deletePet: build.mutation<DeletePetApiResponse, DeletePetApiArg>({
Expand Down Expand Up @@ -2212,7 +2262,8 @@ export type DeleteOrderApiArg = {
/** ID of the order that needs to be deleted */
orderId: number;
};
export type CreateUserApiResponse = unknown;
export type CreateUserApiResponse =
/** status default successful operation */ User;
export type CreateUserApiArg = {
/** Created user object */
user: User;
Expand Down Expand Up @@ -2259,6 +2310,7 @@ export type Pet = {
category?: Category | undefined;
photoUrls: string[];
tags?: Tag[] | undefined;
/** pet status in the store */
status?: ("available" | "pending" | "sold") | undefined;
};
export type ApiResponse = {
Expand All @@ -2271,6 +2323,7 @@ export type Order = {
petId?: number | undefined;
quantity?: number | undefined;
shipDate?: string | undefined;
/** Order Status */
status?: ("placed" | "approved" | "delivered") | undefined;
complete?: boolean | undefined;
};
Expand All @@ -2282,6 +2335,7 @@ export type User = {
email?: string | undefined;
password?: string | undefined;
phone?: string | undefined;
/** User Status */
userStatus?: number | undefined;
};
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('endpoint overrides', () => {
},
],
});
expect(api).not.toMatch(/params: {.*queryArg\.\w+\b(?<!\bstatus)/);
expect(api).not.toMatch(/params: {\n.*queryArg\.\w+\b(?<!\bstatus)/);
expect(api).toMatchSnapshot('should only have the "status" parameter from the endpoints');
});

Expand All @@ -114,8 +114,8 @@ describe('endpoint overrides', () => {
},
],
});
expect(api).not.toMatch(/params: {.*queryArg\.[^\We]*\W/);
expect(api).toMatch(/params: {.*queryArg\.[\we]*\W/);
expect(api).not.toMatch(/params: {\n.*queryArg\.[^\We]*\W/);
expect(api).toMatch(/params: {\n.*queryArg\.[\we]*\W/);
expect(api).toMatchSnapshot('should only have the parameters with an "e"');
});

Expand All @@ -131,8 +131,8 @@ describe('endpoint overrides', () => {
},
],
});
expect(api).not.toMatch(/params: {.*queryArg\.[^\Wef]*\W/);
expect(api).toMatch(/params: {.*queryArg\.[\wef]*\W/);
expect(api).not.toMatch(/params: {\n.*queryArg\.[^\Wef]*\W/);
expect(api).toMatch(/params: {\n.*queryArg\.[\wef]*\W/);
expect(api).toMatchSnapshot('should only have the parameters with an "e" or "f"');
});

Expand Down

0 comments on commit 3585e82

Please sign in to comment.