From 7e2e691ae956fb4785192729c5b8a54080f22eb3 Mon Sep 17 00:00:00 2001 From: Stijn Van Hulle Date: Sat, 9 Mar 2024 22:23:16 +0100 Subject: [PATCH] chore: update --- .../hooks/userController/useCreateUser.ts | 14 +- .../useCreateUsersWithListInput.ts | 14 +- .../hooks/userController/useDeleteUser.ts | 12 +- .../hooks/userController/useUpdateUser.ts | 14 +- .../src/gen/hooks/useAddPetHook.ts | 6 +- .../src/gen/hooks/useCreateUserHook.ts | 6 +- .../hooks/useCreateUsersWithListInputHook.ts | 6 +- .../src/gen/hooks/useDeleteOrderHook.ts | 4 +- .../src/gen/hooks/useDeletePetHook.ts | 4 +- .../src/gen/hooks/useDeleteUserHook.ts | 4 +- .../src/gen/hooks/usePlaceOrderHook.ts | 6 +- .../src/gen/hooks/usePlaceOrderPatchHook.ts | 6 +- .../src/gen/hooks/useUpdatePetHook.ts | 6 +- .../src/gen/hooks/useUpdatePetWithFormHook.ts | 4 +- .../src/gen/hooks/useUpdateUserHook.ts | 6 +- .../src/gen/hooks/useUploadFileHook.ts | 6 +- examples/react-query-v5/src/gen/index.ts | 2 +- .../src/gen/hooks/useAddPetHook.ts | 14 +- .../src/gen/hooks/useCreateUserHook.ts | 14 +- .../hooks/useCreateUsersWithListInputHook.ts | 14 +- .../src/gen/hooks/useDeleteOrderHook.ts | 12 +- .../src/gen/hooks/useDeletePetHook.ts | 12 +- .../src/gen/hooks/useDeleteUserHook.ts | 12 +- .../src/gen/hooks/usePlaceOrderHook.ts | 14 +- .../src/gen/hooks/usePlaceOrderPatchHook.ts | 14 +- .../src/gen/hooks/useUpdatePetHook.ts | 14 +- .../src/gen/hooks/useUpdatePetWithFormHook.ts | 12 +- .../src/gen/hooks/useUpdateUserHook.ts | 14 +- .../src/gen/hooks/useUploadFileHook.ts | 14 +- examples/simple-single/src/gen/hooks.ts | 160 +++++------------- .../solid-query/src/gen/hooks/addPetQuery.ts | 26 +-- .../src/gen/hooks/createUserQuery.ts | 26 +-- .../hooks/createUsersWithListInputQuery.ts | 26 +-- .../src/gen/hooks/deleteOrderQuery.ts | 24 +-- .../src/gen/hooks/deletePetQuery.ts | 24 +-- .../src/gen/hooks/deleteUserQuery.ts | 24 +-- .../src/gen/hooks/placeOrderPatchQuery.ts | 26 +-- .../src/gen/hooks/placeOrderQuery.ts | 26 +-- .../src/gen/hooks/updatePetQuery.ts | 26 +-- .../src/gen/hooks/updatePetWithFormQuery.ts | 24 +-- .../src/gen/hooks/updateUserQuery.ts | 26 +-- .../src/gen/hooks/uploadFileQuery.ts | 26 +-- .../svelte-query/src/gen/hooks/addPetQuery.ts | 26 +-- .../src/gen/hooks/createUserQuery.ts | 26 +-- .../hooks/createUsersWithListInputQuery.ts | 26 +-- .../src/gen/hooks/deleteOrderQuery.ts | 24 +-- .../src/gen/hooks/deletePetQuery.ts | 24 +-- .../src/gen/hooks/deleteUserQuery.ts | 24 +-- .../src/gen/hooks/placeOrderPatchQuery.ts | 26 +-- .../src/gen/hooks/placeOrderQuery.ts | 26 +-- .../src/gen/hooks/updatePetQuery.ts | 26 +-- .../src/gen/hooks/updatePetWithFormQuery.ts | 24 +-- .../src/gen/hooks/updateUserQuery.ts | 26 +-- .../src/gen/hooks/uploadFileQuery.ts | 26 +-- .../core/src/utils/FunctionParams.test.ts | 2 + packages/core/src/utils/FunctionParams.ts | 26 ++- .../src/components/Mutation.tsx | 29 +--- 57 files changed, 240 insertions(+), 865 deletions(-) diff --git a/examples/advanced/src/gen/clients/hooks/userController/useCreateUser.ts b/examples/advanced/src/gen/clients/hooks/userController/useCreateUser.ts index 5cdee5c76..d2c948f31 100644 --- a/examples/advanced/src/gen/clients/hooks/userController/useCreateUser.ts +++ b/examples/advanced/src/gen/clients/hooks/userController/useCreateUser.ts @@ -22,18 +22,12 @@ type CreateUser = { * @summary Create user * @link /user */ export function useCreateUser(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: CreateUser['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/user`, diff --git a/examples/advanced/src/gen/clients/hooks/userController/useCreateUsersWithListInput.ts b/examples/advanced/src/gen/clients/hooks/userController/useCreateUsersWithListInput.ts index 243463cab..c0789c36c 100644 --- a/examples/advanced/src/gen/clients/hooks/userController/useCreateUsersWithListInput.ts +++ b/examples/advanced/src/gen/clients/hooks/userController/useCreateUsersWithListInput.ts @@ -25,18 +25,12 @@ type CreateUsersWithListInput = { * @summary Creates list of users with given input array * @link /user/createWithList */ export function useCreateUsersWithListInput(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: CreateUsersWithListInput['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/user/createWithList`, diff --git a/examples/advanced/src/gen/clients/hooks/userController/useDeleteUser.ts b/examples/advanced/src/gen/clients/hooks/userController/useDeleteUser.ts index a1045b9f9..fd362acfc 100644 --- a/examples/advanced/src/gen/clients/hooks/userController/useDeleteUser.ts +++ b/examples/advanced/src/gen/clients/hooks/userController/useDeleteUser.ts @@ -22,17 +22,11 @@ type DeleteUser = { * @summary Delete user * @link /user/:username */ export function useDeleteUser(username: DeleteUserPathParams['username'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: DeleteUser['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ + return useMutation({ mutationFn: async () => { const res = await client({ method: 'delete', diff --git a/examples/advanced/src/gen/clients/hooks/userController/useUpdateUser.ts b/examples/advanced/src/gen/clients/hooks/userController/useUpdateUser.ts index 8f76dc1f4..d1a7b5164 100644 --- a/examples/advanced/src/gen/clients/hooks/userController/useUpdateUser.ts +++ b/examples/advanced/src/gen/clients/hooks/userController/useUpdateUser.ts @@ -22,18 +22,12 @@ type UpdateUser = { * @summary Update user * @link /user/:username */ export function useUpdateUser(username: UpdateUserPathParams['username'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UpdateUser['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'put', url: `/user/${username}`, diff --git a/examples/react-query-v5/src/gen/hooks/useAddPetHook.ts b/examples/react-query-v5/src/gen/hooks/useAddPetHook.ts index 72df8654e..259b59cce 100644 --- a/examples/react-query-v5/src/gen/hooks/useAddPetHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useAddPetHook.ts @@ -23,15 +23,13 @@ type AddPet = { * @summary Add a new pet to the store * @link /pet */ export function useAddPetHook(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: AddPet['client']['parameters'] } = {}) { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} const invalidationOnSuccess = useInvalidationForMutation('useAddPetHook') return useMutation({ - mutationFn: async ({ data }) => { + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/pet`, diff --git a/examples/react-query-v5/src/gen/hooks/useCreateUserHook.ts b/examples/react-query-v5/src/gen/hooks/useCreateUserHook.ts index a72c408d9..523495e21 100644 --- a/examples/react-query-v5/src/gen/hooks/useCreateUserHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useCreateUserHook.ts @@ -23,15 +23,13 @@ type CreateUser = { * @summary Create user * @link /user */ export function useCreateUserHook(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: CreateUser['client']['parameters'] } = {}) { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} const invalidationOnSuccess = useInvalidationForMutation('useCreateUserHook') return useMutation({ - mutationFn: async ({ data }) => { + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/user`, diff --git a/examples/react-query-v5/src/gen/hooks/useCreateUsersWithListInputHook.ts b/examples/react-query-v5/src/gen/hooks/useCreateUsersWithListInputHook.ts index 9dfea6075..4ea07ce2b 100644 --- a/examples/react-query-v5/src/gen/hooks/useCreateUsersWithListInputHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useCreateUsersWithListInputHook.ts @@ -23,15 +23,13 @@ type CreateUsersWithListInput = { * @summary Creates list of users with given input array * @link /user/createWithList */ export function useCreateUsersWithListInputHook(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: CreateUsersWithListInput['client']['parameters'] } = {}) { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} const invalidationOnSuccess = useInvalidationForMutation('useCreateUsersWithListInputHook') return useMutation({ - mutationFn: async ({ data }) => { + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/user/createWithList`, diff --git a/examples/react-query-v5/src/gen/hooks/useDeleteOrderHook.ts b/examples/react-query-v5/src/gen/hooks/useDeleteOrderHook.ts index f1f00ec8a..e3ab8c2a5 100644 --- a/examples/react-query-v5/src/gen/hooks/useDeleteOrderHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useDeleteOrderHook.ts @@ -23,9 +23,7 @@ type DeleteOrder = { * @summary Delete purchase order by ID * @link /store/order/:orderId */ export function useDeleteOrderHook(orderId: DeleteOrderPathParams['orderId'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: DeleteOrder['client']['parameters'] } = {}) { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} diff --git a/examples/react-query-v5/src/gen/hooks/useDeletePetHook.ts b/examples/react-query-v5/src/gen/hooks/useDeletePetHook.ts index 36cd92e0e..04f4a5e57 100644 --- a/examples/react-query-v5/src/gen/hooks/useDeletePetHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useDeletePetHook.ts @@ -23,9 +23,7 @@ type DeletePet = { * @summary Deletes a pet * @link /pet/:petId */ export function useDeletePetHook(petId: DeletePetPathParams['petId'], headers?: DeletePet['headerParams'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: DeletePet['client']['parameters'] } = {}) { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} diff --git a/examples/react-query-v5/src/gen/hooks/useDeleteUserHook.ts b/examples/react-query-v5/src/gen/hooks/useDeleteUserHook.ts index 06131a307..b7193d48b 100644 --- a/examples/react-query-v5/src/gen/hooks/useDeleteUserHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useDeleteUserHook.ts @@ -23,9 +23,7 @@ type DeleteUser = { * @summary Delete user * @link /user/:username */ export function useDeleteUserHook(username: DeleteUserPathParams['username'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: DeleteUser['client']['parameters'] } = {}) { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} diff --git a/examples/react-query-v5/src/gen/hooks/usePlaceOrderHook.ts b/examples/react-query-v5/src/gen/hooks/usePlaceOrderHook.ts index 26f7316c6..5bafd48b5 100644 --- a/examples/react-query-v5/src/gen/hooks/usePlaceOrderHook.ts +++ b/examples/react-query-v5/src/gen/hooks/usePlaceOrderHook.ts @@ -23,15 +23,13 @@ type PlaceOrder = { * @summary Place an order for a pet * @link /store/order */ export function usePlaceOrderHook(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: PlaceOrder['client']['parameters'] } = {}) { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} const invalidationOnSuccess = useInvalidationForMutation('usePlaceOrderHook') return useMutation({ - mutationFn: async ({ data }) => { + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/store/order`, diff --git a/examples/react-query-v5/src/gen/hooks/usePlaceOrderPatchHook.ts b/examples/react-query-v5/src/gen/hooks/usePlaceOrderPatchHook.ts index 9a0a972ac..7b4d1ab8d 100644 --- a/examples/react-query-v5/src/gen/hooks/usePlaceOrderPatchHook.ts +++ b/examples/react-query-v5/src/gen/hooks/usePlaceOrderPatchHook.ts @@ -23,15 +23,13 @@ type PlaceOrderPatch = { * @summary Place an order for a pet with patch * @link /store/order */ export function usePlaceOrderPatchHook(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: PlaceOrderPatch['client']['parameters'] } = {}) { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} const invalidationOnSuccess = useInvalidationForMutation('usePlaceOrderPatchHook') return useMutation({ - mutationFn: async ({ data }) => { + mutationFn: async (data) => { const res = await client({ method: 'patch', url: `/store/order`, diff --git a/examples/react-query-v5/src/gen/hooks/useUpdatePetHook.ts b/examples/react-query-v5/src/gen/hooks/useUpdatePetHook.ts index 7b88c5375..ff0959c4b 100644 --- a/examples/react-query-v5/src/gen/hooks/useUpdatePetHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useUpdatePetHook.ts @@ -23,15 +23,13 @@ type UpdatePet = { * @summary Update an existing pet * @link /pet */ export function useUpdatePetHook(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UpdatePet['client']['parameters'] } = {}) { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} const invalidationOnSuccess = useInvalidationForMutation('useUpdatePetHook') return useMutation({ - mutationFn: async ({ data }) => { + mutationFn: async (data) => { const res = await client({ method: 'put', url: `/pet`, diff --git a/examples/react-query-v5/src/gen/hooks/useUpdatePetWithFormHook.ts b/examples/react-query-v5/src/gen/hooks/useUpdatePetWithFormHook.ts index 5a8e1cd88..8499cc546 100644 --- a/examples/react-query-v5/src/gen/hooks/useUpdatePetWithFormHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useUpdatePetWithFormHook.ts @@ -27,9 +27,7 @@ type UpdatePetWithForm = { * @summary Updates a pet in the store with form data * @link /pet/:petId */ export function useUpdatePetWithFormHook(petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithForm['queryParams'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UpdatePetWithForm['client']['parameters'] } = {}) { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} diff --git a/examples/react-query-v5/src/gen/hooks/useUpdateUserHook.ts b/examples/react-query-v5/src/gen/hooks/useUpdateUserHook.ts index 4082be2aa..6d8de8674 100644 --- a/examples/react-query-v5/src/gen/hooks/useUpdateUserHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useUpdateUserHook.ts @@ -23,15 +23,13 @@ type UpdateUser = { * @summary Update user * @link /user/:username */ export function useUpdateUserHook(username: UpdateUserPathParams['username'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UpdateUser['client']['parameters'] } = {}) { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} const invalidationOnSuccess = useInvalidationForMutation('useUpdateUserHook') return useMutation({ - mutationFn: async ({ data }) => { + mutationFn: async (data) => { const res = await client({ method: 'put', url: `/user/${username}`, diff --git a/examples/react-query-v5/src/gen/hooks/useUploadFileHook.ts b/examples/react-query-v5/src/gen/hooks/useUploadFileHook.ts index 8e59fb12f..9ac955a82 100644 --- a/examples/react-query-v5/src/gen/hooks/useUploadFileHook.ts +++ b/examples/react-query-v5/src/gen/hooks/useUploadFileHook.ts @@ -22,15 +22,13 @@ type UploadFile = { * @summary uploads an image * @link /pet/:petId/uploadImage */ export function useUploadFileHook(petId: UploadFilePathParams['petId'], params?: UploadFile['queryParams'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UploadFile['client']['parameters'] } = {}) { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} const invalidationOnSuccess = useInvalidationForMutation('useUploadFileHook') return useMutation({ - mutationFn: async ({ data }) => { + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, diff --git a/examples/react-query-v5/src/gen/index.ts b/examples/react-query-v5/src/gen/index.ts index 6e6f12d44..9d83c2121 100644 --- a/examples/react-query-v5/src/gen/index.ts +++ b/examples/react-query-v5/src/gen/index.ts @@ -1,2 +1,2 @@ -export * from './models/index' export * from './hooks/index' +export * from './models/index' diff --git a/examples/react-query/src/gen/hooks/useAddPetHook.ts b/examples/react-query/src/gen/hooks/useAddPetHook.ts index 413eb2ab8..511669a7c 100644 --- a/examples/react-query/src/gen/hooks/useAddPetHook.ts +++ b/examples/react-query/src/gen/hooks/useAddPetHook.ts @@ -22,18 +22,12 @@ type AddPet = { * @summary Add a new pet to the store * @link /pet */ export function useAddPetHook(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: AddPet['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/pet`, diff --git a/examples/react-query/src/gen/hooks/useCreateUserHook.ts b/examples/react-query/src/gen/hooks/useCreateUserHook.ts index 97a09822e..9148f232e 100644 --- a/examples/react-query/src/gen/hooks/useCreateUserHook.ts +++ b/examples/react-query/src/gen/hooks/useCreateUserHook.ts @@ -22,18 +22,12 @@ type CreateUser = { * @summary Create user * @link /user */ export function useCreateUserHook(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: CreateUser['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/user`, diff --git a/examples/react-query/src/gen/hooks/useCreateUsersWithListInputHook.ts b/examples/react-query/src/gen/hooks/useCreateUsersWithListInputHook.ts index 402c97e00..062ce7cdd 100644 --- a/examples/react-query/src/gen/hooks/useCreateUsersWithListInputHook.ts +++ b/examples/react-query/src/gen/hooks/useCreateUsersWithListInputHook.ts @@ -22,18 +22,12 @@ type CreateUsersWithListInput = { * @summary Creates list of users with given input array * @link /user/createWithList */ export function useCreateUsersWithListInputHook(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: CreateUsersWithListInput['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/user/createWithList`, diff --git a/examples/react-query/src/gen/hooks/useDeleteOrderHook.ts b/examples/react-query/src/gen/hooks/useDeleteOrderHook.ts index 229cd3091..f309c6ec9 100644 --- a/examples/react-query/src/gen/hooks/useDeleteOrderHook.ts +++ b/examples/react-query/src/gen/hooks/useDeleteOrderHook.ts @@ -22,17 +22,11 @@ type DeleteOrder = { * @summary Delete purchase order by ID * @link /store/order/:orderId */ export function useDeleteOrderHook(orderId: DeleteOrderPathParams['orderId'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: DeleteOrder['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ + return useMutation({ mutationFn: async () => { const res = await client({ method: 'delete', diff --git a/examples/react-query/src/gen/hooks/useDeletePetHook.ts b/examples/react-query/src/gen/hooks/useDeletePetHook.ts index 02bec7f44..347d9fa05 100644 --- a/examples/react-query/src/gen/hooks/useDeletePetHook.ts +++ b/examples/react-query/src/gen/hooks/useDeletePetHook.ts @@ -22,17 +22,11 @@ type DeletePet = { * @summary Deletes a pet * @link /pet/:petId */ export function useDeletePetHook(petId: DeletePetPathParams['petId'], headers?: DeletePet['headerParams'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: DeletePet['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ + return useMutation({ mutationFn: async () => { const res = await client({ method: 'delete', diff --git a/examples/react-query/src/gen/hooks/useDeleteUserHook.ts b/examples/react-query/src/gen/hooks/useDeleteUserHook.ts index 7be4a7f48..cc2b5dc79 100644 --- a/examples/react-query/src/gen/hooks/useDeleteUserHook.ts +++ b/examples/react-query/src/gen/hooks/useDeleteUserHook.ts @@ -22,17 +22,11 @@ type DeleteUser = { * @summary Delete user * @link /user/:username */ export function useDeleteUserHook(username: DeleteUserPathParams['username'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: DeleteUser['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ + return useMutation({ mutationFn: async () => { const res = await client({ method: 'delete', diff --git a/examples/react-query/src/gen/hooks/usePlaceOrderHook.ts b/examples/react-query/src/gen/hooks/usePlaceOrderHook.ts index cb3cde940..9a26ee5ae 100644 --- a/examples/react-query/src/gen/hooks/usePlaceOrderHook.ts +++ b/examples/react-query/src/gen/hooks/usePlaceOrderHook.ts @@ -22,18 +22,12 @@ type PlaceOrder = { * @summary Place an order for a pet * @link /store/order */ export function usePlaceOrderHook(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: PlaceOrder['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/store/order`, diff --git a/examples/react-query/src/gen/hooks/usePlaceOrderPatchHook.ts b/examples/react-query/src/gen/hooks/usePlaceOrderPatchHook.ts index 81a16a5b7..266a2f414 100644 --- a/examples/react-query/src/gen/hooks/usePlaceOrderPatchHook.ts +++ b/examples/react-query/src/gen/hooks/usePlaceOrderPatchHook.ts @@ -22,18 +22,12 @@ type PlaceOrderPatch = { * @summary Place an order for a pet with patch * @link /store/order */ export function usePlaceOrderPatchHook(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: PlaceOrderPatch['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'patch', url: `/store/order`, diff --git a/examples/react-query/src/gen/hooks/useUpdatePetHook.ts b/examples/react-query/src/gen/hooks/useUpdatePetHook.ts index 12facbad9..46b8c3ebf 100644 --- a/examples/react-query/src/gen/hooks/useUpdatePetHook.ts +++ b/examples/react-query/src/gen/hooks/useUpdatePetHook.ts @@ -22,18 +22,12 @@ type UpdatePet = { * @summary Update an existing pet * @link /pet */ export function useUpdatePetHook(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UpdatePet['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'put', url: `/pet`, diff --git a/examples/react-query/src/gen/hooks/useUpdatePetWithFormHook.ts b/examples/react-query/src/gen/hooks/useUpdatePetWithFormHook.ts index 850302a8b..3d56dea46 100644 --- a/examples/react-query/src/gen/hooks/useUpdatePetWithFormHook.ts +++ b/examples/react-query/src/gen/hooks/useUpdatePetWithFormHook.ts @@ -26,17 +26,11 @@ type UpdatePetWithForm = { * @summary Updates a pet in the store with form data * @link /pet/:petId */ export function useUpdatePetWithFormHook(petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithForm['queryParams'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UpdatePetWithForm['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ + return useMutation({ mutationFn: async () => { const res = await client({ method: 'post', diff --git a/examples/react-query/src/gen/hooks/useUpdateUserHook.ts b/examples/react-query/src/gen/hooks/useUpdateUserHook.ts index 4470468f9..18c4c348c 100644 --- a/examples/react-query/src/gen/hooks/useUpdateUserHook.ts +++ b/examples/react-query/src/gen/hooks/useUpdateUserHook.ts @@ -22,18 +22,12 @@ type UpdateUser = { * @summary Update user * @link /user/:username */ export function useUpdateUserHook(username: UpdateUserPathParams['username'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UpdateUser['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'put', url: `/user/${username}`, diff --git a/examples/react-query/src/gen/hooks/useUploadFileHook.ts b/examples/react-query/src/gen/hooks/useUploadFileHook.ts index c8fa0e9d7..cf7e200dd 100644 --- a/examples/react-query/src/gen/hooks/useUploadFileHook.ts +++ b/examples/react-query/src/gen/hooks/useUploadFileHook.ts @@ -21,18 +21,12 @@ type UploadFile = { * @summary uploads an image * @link /pet/:petId/uploadImage */ export function useUploadFileHook(petId: UploadFilePathParams['petId'], params?: UploadFile['queryParams'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UploadFile['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, diff --git a/examples/simple-single/src/gen/hooks.ts b/examples/simple-single/src/gen/hooks.ts index 8493a9d7e..d6d8a3349 100644 --- a/examples/simple-single/src/gen/hooks.ts +++ b/examples/simple-single/src/gen/hooks.ts @@ -87,18 +87,12 @@ type UpdatePet = { * @summary Update an existing pet * @link /pet */ export function useUpdatePet(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UpdatePet['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'put', url: `/pet`, @@ -130,18 +124,12 @@ type AddPet = { * @summary Add a new pet to the store * @link /pet */ export function useAddPet(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: AddPet['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/pet`, @@ -353,17 +341,11 @@ type UpdatePetWithForm = { * @summary Updates a pet in the store with form data * @link /pet/:petId */ export function useUpdatePetWithForm(petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithForm['queryParams'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UpdatePetWithForm['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ + return useMutation({ mutationFn: async () => { const res = await client({ method: 'post', @@ -396,17 +378,11 @@ type DeletePet = { * @summary Deletes a pet * @link /pet/:petId */ export function useDeletePet(petId: DeletePetPathParams['petId'], headers?: DeletePet['headerParams'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: DeletePet['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ + return useMutation({ mutationFn: async () => { const res = await client({ method: 'delete', @@ -438,18 +414,12 @@ type UploadFile = { * @summary uploads an image * @link /pet/:petId/uploadImage */ export function useUploadFile(petId: UploadFilePathParams['petId'], params?: UploadFile['queryParams'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UploadFile['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, @@ -539,18 +509,12 @@ type PlaceOrder = { * @summary Place an order for a pet * @link /store/order */ export function usePlaceOrder(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: PlaceOrder['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/store/order`, @@ -582,18 +546,12 @@ type PlaceOrderPatch = { * @summary Place an order for a pet with patch * @link /store/order */ export function usePlaceOrderPatch(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: PlaceOrderPatch['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'patch', url: `/store/order`, @@ -684,17 +642,11 @@ type DeleteOrder = { * @summary Delete purchase order by ID * @link /store/order/:orderId */ export function useDeleteOrder(orderId: DeleteOrderPathParams['orderId'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: DeleteOrder['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ + return useMutation({ mutationFn: async () => { const res = await client({ method: 'delete', @@ -726,18 +678,12 @@ type CreateUser = { * @summary Create user * @link /user */ export function useCreateUser(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: CreateUser['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/user`, @@ -769,18 +715,12 @@ type CreateUsersWithListInput = { * @summary Creates list of users with given input array * @link /user/createWithList */ export function useCreateUsersWithListInput(options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: CreateUsersWithListInput['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/user/createWithList`, @@ -983,18 +923,12 @@ type UpdateUser = { * @summary Update user * @link /user/:username */ export function useUpdateUser(username: UpdateUserPathParams['username'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: UpdateUser['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ - mutationFn: async ({ data }) => { + return useMutation({ + mutationFn: async (data) => { const res = await client({ method: 'put', url: `/user/${username}`, @@ -1026,17 +960,11 @@ type DeleteUser = { * @summary Delete user * @link /user/:username */ export function useDeleteUser(username: DeleteUserPathParams['username'], options: { - mutation?: UseMutationOptions + mutation?: UseMutationOptions client?: DeleteUser['client']['parameters'] -} = {}): UseMutationResult { +} = {}): UseMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return useMutation({ + return useMutation({ mutationFn: async () => { const res = await client({ method: 'delete', diff --git a/examples/solid-query/src/gen/hooks/addPetQuery.ts b/examples/solid-query/src/gen/hooks/addPetQuery.ts index a0f576b3f..2c721478a 100644 --- a/examples/solid-query/src/gen/hooks/addPetQuery.ts +++ b/examples/solid-query/src/gen/hooks/addPetQuery.ts @@ -23,31 +23,13 @@ type AddPet = { * @link /pet */ export function addPetQuery( options: { - mutation?: CreateMutationOptions< - AddPet['response'], - AddPet['error'], - { - data: AddPet['request'] - } - > + mutation?: CreateMutationOptions client?: AddPet['client']['parameters'] } = {}, -): CreateMutationResult< - AddPet['response'], - AddPet['error'], - { - data: AddPet['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - AddPet['response'], - AddPet['error'], - { - data: AddPet['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/pet`, diff --git a/examples/solid-query/src/gen/hooks/createUserQuery.ts b/examples/solid-query/src/gen/hooks/createUserQuery.ts index 307327deb..a23e4b349 100644 --- a/examples/solid-query/src/gen/hooks/createUserQuery.ts +++ b/examples/solid-query/src/gen/hooks/createUserQuery.ts @@ -23,31 +23,13 @@ type CreateUser = { * @link /user */ export function createUserQuery( options: { - mutation?: CreateMutationOptions< - CreateUser['response'], - CreateUser['error'], - { - data: CreateUser['request'] - } - > + mutation?: CreateMutationOptions client?: CreateUser['client']['parameters'] } = {}, -): CreateMutationResult< - CreateUser['response'], - CreateUser['error'], - { - data: CreateUser['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - CreateUser['response'], - CreateUser['error'], - { - data: CreateUser['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/user`, diff --git a/examples/solid-query/src/gen/hooks/createUsersWithListInputQuery.ts b/examples/solid-query/src/gen/hooks/createUsersWithListInputQuery.ts index 1468f03a3..b67002f62 100644 --- a/examples/solid-query/src/gen/hooks/createUsersWithListInputQuery.ts +++ b/examples/solid-query/src/gen/hooks/createUsersWithListInputQuery.ts @@ -23,31 +23,13 @@ type CreateUsersWithListInput = { * @link /user/createWithList */ export function createUsersWithListInputQuery( options: { - mutation?: CreateMutationOptions< - CreateUsersWithListInput['response'], - CreateUsersWithListInput['error'], - { - data: CreateUsersWithListInput['request'] - } - > + mutation?: CreateMutationOptions client?: CreateUsersWithListInput['client']['parameters'] } = {}, -): CreateMutationResult< - CreateUsersWithListInput['response'], - CreateUsersWithListInput['error'], - { - data: CreateUsersWithListInput['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - CreateUsersWithListInput['response'], - CreateUsersWithListInput['error'], - { - data: CreateUsersWithListInput['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/user/createWithList`, diff --git a/examples/solid-query/src/gen/hooks/deleteOrderQuery.ts b/examples/solid-query/src/gen/hooks/deleteOrderQuery.ts index efb0f2a16..550b26514 100644 --- a/examples/solid-query/src/gen/hooks/deleteOrderQuery.ts +++ b/examples/solid-query/src/gen/hooks/deleteOrderQuery.ts @@ -24,30 +24,12 @@ type DeleteOrder = { export function deleteOrderQuery( orderId: DeleteOrderPathParams['orderId'], options: { - mutation?: CreateMutationOptions< - DeleteOrder['response'], - DeleteOrder['error'], - { - data: DeleteOrder['request'] - } - > + mutation?: CreateMutationOptions client?: DeleteOrder['client']['parameters'] } = {}, -): CreateMutationResult< - DeleteOrder['response'], - DeleteOrder['error'], - { - data: DeleteOrder['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - DeleteOrder['response'], - DeleteOrder['error'], - { - data: DeleteOrder['request'] - } - >({ + return createMutation({ mutationFn: async () => { const res = await client({ method: 'delete', diff --git a/examples/solid-query/src/gen/hooks/deletePetQuery.ts b/examples/solid-query/src/gen/hooks/deletePetQuery.ts index c1fe88531..bc3ffa309 100644 --- a/examples/solid-query/src/gen/hooks/deletePetQuery.ts +++ b/examples/solid-query/src/gen/hooks/deletePetQuery.ts @@ -25,30 +25,12 @@ export function deletePetQuery( petId: DeletePetPathParams['petId'], headers?: DeletePet['headerParams'], options: { - mutation?: CreateMutationOptions< - DeletePet['response'], - DeletePet['error'], - { - data: DeletePet['request'] - } - > + mutation?: CreateMutationOptions client?: DeletePet['client']['parameters'] } = {}, -): CreateMutationResult< - DeletePet['response'], - DeletePet['error'], - { - data: DeletePet['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - DeletePet['response'], - DeletePet['error'], - { - data: DeletePet['request'] - } - >({ + return createMutation({ mutationFn: async () => { const res = await client({ method: 'delete', diff --git a/examples/solid-query/src/gen/hooks/deleteUserQuery.ts b/examples/solid-query/src/gen/hooks/deleteUserQuery.ts index 891600ca9..5d4e35016 100644 --- a/examples/solid-query/src/gen/hooks/deleteUserQuery.ts +++ b/examples/solid-query/src/gen/hooks/deleteUserQuery.ts @@ -24,30 +24,12 @@ type DeleteUser = { export function deleteUserQuery( username: DeleteUserPathParams['username'], options: { - mutation?: CreateMutationOptions< - DeleteUser['response'], - DeleteUser['error'], - { - data: DeleteUser['request'] - } - > + mutation?: CreateMutationOptions client?: DeleteUser['client']['parameters'] } = {}, -): CreateMutationResult< - DeleteUser['response'], - DeleteUser['error'], - { - data: DeleteUser['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - DeleteUser['response'], - DeleteUser['error'], - { - data: DeleteUser['request'] - } - >({ + return createMutation({ mutationFn: async () => { const res = await client({ method: 'delete', diff --git a/examples/solid-query/src/gen/hooks/placeOrderPatchQuery.ts b/examples/solid-query/src/gen/hooks/placeOrderPatchQuery.ts index 8b84131de..b2f0253c2 100644 --- a/examples/solid-query/src/gen/hooks/placeOrderPatchQuery.ts +++ b/examples/solid-query/src/gen/hooks/placeOrderPatchQuery.ts @@ -23,31 +23,13 @@ type PlaceOrderPatch = { * @link /store/order */ export function placeOrderPatchQuery( options: { - mutation?: CreateMutationOptions< - PlaceOrderPatch['response'], - PlaceOrderPatch['error'], - { - data: PlaceOrderPatch['request'] - } - > + mutation?: CreateMutationOptions client?: PlaceOrderPatch['client']['parameters'] } = {}, -): CreateMutationResult< - PlaceOrderPatch['response'], - PlaceOrderPatch['error'], - { - data: PlaceOrderPatch['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - PlaceOrderPatch['response'], - PlaceOrderPatch['error'], - { - data: PlaceOrderPatch['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'patch', url: `/store/order`, diff --git a/examples/solid-query/src/gen/hooks/placeOrderQuery.ts b/examples/solid-query/src/gen/hooks/placeOrderQuery.ts index 26cca5e8e..d2b58e06c 100644 --- a/examples/solid-query/src/gen/hooks/placeOrderQuery.ts +++ b/examples/solid-query/src/gen/hooks/placeOrderQuery.ts @@ -23,31 +23,13 @@ type PlaceOrder = { * @link /store/order */ export function placeOrderQuery( options: { - mutation?: CreateMutationOptions< - PlaceOrder['response'], - PlaceOrder['error'], - { - data: PlaceOrder['request'] - } - > + mutation?: CreateMutationOptions client?: PlaceOrder['client']['parameters'] } = {}, -): CreateMutationResult< - PlaceOrder['response'], - PlaceOrder['error'], - { - data: PlaceOrder['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - PlaceOrder['response'], - PlaceOrder['error'], - { - data: PlaceOrder['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/store/order`, diff --git a/examples/solid-query/src/gen/hooks/updatePetQuery.ts b/examples/solid-query/src/gen/hooks/updatePetQuery.ts index ec3360088..478a1baa9 100644 --- a/examples/solid-query/src/gen/hooks/updatePetQuery.ts +++ b/examples/solid-query/src/gen/hooks/updatePetQuery.ts @@ -23,31 +23,13 @@ type UpdatePet = { * @link /pet */ export function updatePetQuery( options: { - mutation?: CreateMutationOptions< - UpdatePet['response'], - UpdatePet['error'], - { - data: UpdatePet['request'] - } - > + mutation?: CreateMutationOptions client?: UpdatePet['client']['parameters'] } = {}, -): CreateMutationResult< - UpdatePet['response'], - UpdatePet['error'], - { - data: UpdatePet['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - UpdatePet['response'], - UpdatePet['error'], - { - data: UpdatePet['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'put', url: `/pet`, diff --git a/examples/solid-query/src/gen/hooks/updatePetWithFormQuery.ts b/examples/solid-query/src/gen/hooks/updatePetWithFormQuery.ts index f5a4c67eb..cae67bc21 100644 --- a/examples/solid-query/src/gen/hooks/updatePetWithFormQuery.ts +++ b/examples/solid-query/src/gen/hooks/updatePetWithFormQuery.ts @@ -29,30 +29,12 @@ export function updatePetWithFormQuery( petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithForm['queryParams'], options: { - mutation?: CreateMutationOptions< - UpdatePetWithForm['response'], - UpdatePetWithForm['error'], - { - data: UpdatePetWithForm['request'] - } - > + mutation?: CreateMutationOptions client?: UpdatePetWithForm['client']['parameters'] } = {}, -): CreateMutationResult< - UpdatePetWithForm['response'], - UpdatePetWithForm['error'], - { - data: UpdatePetWithForm['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - UpdatePetWithForm['response'], - UpdatePetWithForm['error'], - { - data: UpdatePetWithForm['request'] - } - >({ + return createMutation({ mutationFn: async () => { const res = await client({ method: 'post', diff --git a/examples/solid-query/src/gen/hooks/updateUserQuery.ts b/examples/solid-query/src/gen/hooks/updateUserQuery.ts index 18bfdb241..6f0d6b894 100644 --- a/examples/solid-query/src/gen/hooks/updateUserQuery.ts +++ b/examples/solid-query/src/gen/hooks/updateUserQuery.ts @@ -24,31 +24,13 @@ type UpdateUser = { export function updateUserQuery( username: UpdateUserPathParams['username'], options: { - mutation?: CreateMutationOptions< - UpdateUser['response'], - UpdateUser['error'], - { - data: UpdateUser['request'] - } - > + mutation?: CreateMutationOptions client?: UpdateUser['client']['parameters'] } = {}, -): CreateMutationResult< - UpdateUser['response'], - UpdateUser['error'], - { - data: UpdateUser['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - UpdateUser['response'], - UpdateUser['error'], - { - data: UpdateUser['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'put', url: `/user/${username}`, diff --git a/examples/solid-query/src/gen/hooks/uploadFileQuery.ts b/examples/solid-query/src/gen/hooks/uploadFileQuery.ts index d8a6d1e9a..567de4f82 100644 --- a/examples/solid-query/src/gen/hooks/uploadFileQuery.ts +++ b/examples/solid-query/src/gen/hooks/uploadFileQuery.ts @@ -24,31 +24,13 @@ export function uploadFileQuery( petId: UploadFilePathParams['petId'], params?: UploadFile['queryParams'], options: { - mutation?: CreateMutationOptions< - UploadFile['response'], - UploadFile['error'], - { - data: UploadFile['request'] - } - > + mutation?: CreateMutationOptions client?: UploadFile['client']['parameters'] } = {}, -): CreateMutationResult< - UploadFile['response'], - UploadFile['error'], - { - data: UploadFile['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - UploadFile['response'], - UploadFile['error'], - { - data: UploadFile['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, diff --git a/examples/svelte-query/src/gen/hooks/addPetQuery.ts b/examples/svelte-query/src/gen/hooks/addPetQuery.ts index dc6573448..3d1d48134 100644 --- a/examples/svelte-query/src/gen/hooks/addPetQuery.ts +++ b/examples/svelte-query/src/gen/hooks/addPetQuery.ts @@ -23,31 +23,13 @@ type AddPet = { * @link /pet */ export function addPetQuery( options: { - mutation?: CreateMutationOptions< - AddPet['response'], - AddPet['error'], - { - data: AddPet['request'] - } - > + mutation?: CreateMutationOptions client?: AddPet['client']['parameters'] } = {}, -): CreateMutationResult< - AddPet['response'], - AddPet['error'], - { - data: AddPet['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - AddPet['response'], - AddPet['error'], - { - data: AddPet['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/pet`, diff --git a/examples/svelte-query/src/gen/hooks/createUserQuery.ts b/examples/svelte-query/src/gen/hooks/createUserQuery.ts index 213321be3..4fdc9f0f7 100644 --- a/examples/svelte-query/src/gen/hooks/createUserQuery.ts +++ b/examples/svelte-query/src/gen/hooks/createUserQuery.ts @@ -23,31 +23,13 @@ type CreateUser = { * @link /user */ export function createUserQuery( options: { - mutation?: CreateMutationOptions< - CreateUser['response'], - CreateUser['error'], - { - data: CreateUser['request'] - } - > + mutation?: CreateMutationOptions client?: CreateUser['client']['parameters'] } = {}, -): CreateMutationResult< - CreateUser['response'], - CreateUser['error'], - { - data: CreateUser['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - CreateUser['response'], - CreateUser['error'], - { - data: CreateUser['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/user`, diff --git a/examples/svelte-query/src/gen/hooks/createUsersWithListInputQuery.ts b/examples/svelte-query/src/gen/hooks/createUsersWithListInputQuery.ts index 5ac49a65c..2e84a2db7 100644 --- a/examples/svelte-query/src/gen/hooks/createUsersWithListInputQuery.ts +++ b/examples/svelte-query/src/gen/hooks/createUsersWithListInputQuery.ts @@ -23,31 +23,13 @@ type CreateUsersWithListInput = { * @link /user/createWithList */ export function createUsersWithListInputQuery( options: { - mutation?: CreateMutationOptions< - CreateUsersWithListInput['response'], - CreateUsersWithListInput['error'], - { - data: CreateUsersWithListInput['request'] - } - > + mutation?: CreateMutationOptions client?: CreateUsersWithListInput['client']['parameters'] } = {}, -): CreateMutationResult< - CreateUsersWithListInput['response'], - CreateUsersWithListInput['error'], - { - data: CreateUsersWithListInput['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - CreateUsersWithListInput['response'], - CreateUsersWithListInput['error'], - { - data: CreateUsersWithListInput['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/user/createWithList`, diff --git a/examples/svelte-query/src/gen/hooks/deleteOrderQuery.ts b/examples/svelte-query/src/gen/hooks/deleteOrderQuery.ts index f58f6d9bd..3afcb1d85 100644 --- a/examples/svelte-query/src/gen/hooks/deleteOrderQuery.ts +++ b/examples/svelte-query/src/gen/hooks/deleteOrderQuery.ts @@ -24,30 +24,12 @@ type DeleteOrder = { export function deleteOrderQuery( orderId: DeleteOrderPathParams['orderId'], options: { - mutation?: CreateMutationOptions< - DeleteOrder['response'], - DeleteOrder['error'], - { - data: DeleteOrder['request'] - } - > + mutation?: CreateMutationOptions client?: DeleteOrder['client']['parameters'] } = {}, -): CreateMutationResult< - DeleteOrder['response'], - DeleteOrder['error'], - { - data: DeleteOrder['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - DeleteOrder['response'], - DeleteOrder['error'], - { - data: DeleteOrder['request'] - } - >({ + return createMutation({ mutationFn: async () => { const res = await client({ method: 'delete', diff --git a/examples/svelte-query/src/gen/hooks/deletePetQuery.ts b/examples/svelte-query/src/gen/hooks/deletePetQuery.ts index 58d800205..a146b3a46 100644 --- a/examples/svelte-query/src/gen/hooks/deletePetQuery.ts +++ b/examples/svelte-query/src/gen/hooks/deletePetQuery.ts @@ -25,30 +25,12 @@ export function deletePetQuery( petId: DeletePetPathParams['petId'], headers?: DeletePet['headerParams'], options: { - mutation?: CreateMutationOptions< - DeletePet['response'], - DeletePet['error'], - { - data: DeletePet['request'] - } - > + mutation?: CreateMutationOptions client?: DeletePet['client']['parameters'] } = {}, -): CreateMutationResult< - DeletePet['response'], - DeletePet['error'], - { - data: DeletePet['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - DeletePet['response'], - DeletePet['error'], - { - data: DeletePet['request'] - } - >({ + return createMutation({ mutationFn: async () => { const res = await client({ method: 'delete', diff --git a/examples/svelte-query/src/gen/hooks/deleteUserQuery.ts b/examples/svelte-query/src/gen/hooks/deleteUserQuery.ts index 0064a1594..8ce3e7c90 100644 --- a/examples/svelte-query/src/gen/hooks/deleteUserQuery.ts +++ b/examples/svelte-query/src/gen/hooks/deleteUserQuery.ts @@ -24,30 +24,12 @@ type DeleteUser = { export function deleteUserQuery( username: DeleteUserPathParams['username'], options: { - mutation?: CreateMutationOptions< - DeleteUser['response'], - DeleteUser['error'], - { - data: DeleteUser['request'] - } - > + mutation?: CreateMutationOptions client?: DeleteUser['client']['parameters'] } = {}, -): CreateMutationResult< - DeleteUser['response'], - DeleteUser['error'], - { - data: DeleteUser['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - DeleteUser['response'], - DeleteUser['error'], - { - data: DeleteUser['request'] - } - >({ + return createMutation({ mutationFn: async () => { const res = await client({ method: 'delete', diff --git a/examples/svelte-query/src/gen/hooks/placeOrderPatchQuery.ts b/examples/svelte-query/src/gen/hooks/placeOrderPatchQuery.ts index b429d8236..ee5177b9d 100644 --- a/examples/svelte-query/src/gen/hooks/placeOrderPatchQuery.ts +++ b/examples/svelte-query/src/gen/hooks/placeOrderPatchQuery.ts @@ -23,31 +23,13 @@ type PlaceOrderPatch = { * @link /store/order */ export function placeOrderPatchQuery( options: { - mutation?: CreateMutationOptions< - PlaceOrderPatch['response'], - PlaceOrderPatch['error'], - { - data: PlaceOrderPatch['request'] - } - > + mutation?: CreateMutationOptions client?: PlaceOrderPatch['client']['parameters'] } = {}, -): CreateMutationResult< - PlaceOrderPatch['response'], - PlaceOrderPatch['error'], - { - data: PlaceOrderPatch['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - PlaceOrderPatch['response'], - PlaceOrderPatch['error'], - { - data: PlaceOrderPatch['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'patch', url: `/store/order`, diff --git a/examples/svelte-query/src/gen/hooks/placeOrderQuery.ts b/examples/svelte-query/src/gen/hooks/placeOrderQuery.ts index 3b237f6ba..4c50d2dac 100644 --- a/examples/svelte-query/src/gen/hooks/placeOrderQuery.ts +++ b/examples/svelte-query/src/gen/hooks/placeOrderQuery.ts @@ -23,31 +23,13 @@ type PlaceOrder = { * @link /store/order */ export function placeOrderQuery( options: { - mutation?: CreateMutationOptions< - PlaceOrder['response'], - PlaceOrder['error'], - { - data: PlaceOrder['request'] - } - > + mutation?: CreateMutationOptions client?: PlaceOrder['client']['parameters'] } = {}, -): CreateMutationResult< - PlaceOrder['response'], - PlaceOrder['error'], - { - data: PlaceOrder['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - PlaceOrder['response'], - PlaceOrder['error'], - { - data: PlaceOrder['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/store/order`, diff --git a/examples/svelte-query/src/gen/hooks/updatePetQuery.ts b/examples/svelte-query/src/gen/hooks/updatePetQuery.ts index 72b459aa0..470ba392f 100644 --- a/examples/svelte-query/src/gen/hooks/updatePetQuery.ts +++ b/examples/svelte-query/src/gen/hooks/updatePetQuery.ts @@ -23,31 +23,13 @@ type UpdatePet = { * @link /pet */ export function updatePetQuery( options: { - mutation?: CreateMutationOptions< - UpdatePet['response'], - UpdatePet['error'], - { - data: UpdatePet['request'] - } - > + mutation?: CreateMutationOptions client?: UpdatePet['client']['parameters'] } = {}, -): CreateMutationResult< - UpdatePet['response'], - UpdatePet['error'], - { - data: UpdatePet['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - UpdatePet['response'], - UpdatePet['error'], - { - data: UpdatePet['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'put', url: `/pet`, diff --git a/examples/svelte-query/src/gen/hooks/updatePetWithFormQuery.ts b/examples/svelte-query/src/gen/hooks/updatePetWithFormQuery.ts index c9d149aa5..70b6bf858 100644 --- a/examples/svelte-query/src/gen/hooks/updatePetWithFormQuery.ts +++ b/examples/svelte-query/src/gen/hooks/updatePetWithFormQuery.ts @@ -29,30 +29,12 @@ export function updatePetWithFormQuery( petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithForm['queryParams'], options: { - mutation?: CreateMutationOptions< - UpdatePetWithForm['response'], - UpdatePetWithForm['error'], - { - data: UpdatePetWithForm['request'] - } - > + mutation?: CreateMutationOptions client?: UpdatePetWithForm['client']['parameters'] } = {}, -): CreateMutationResult< - UpdatePetWithForm['response'], - UpdatePetWithForm['error'], - { - data: UpdatePetWithForm['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - UpdatePetWithForm['response'], - UpdatePetWithForm['error'], - { - data: UpdatePetWithForm['request'] - } - >({ + return createMutation({ mutationFn: async () => { const res = await client({ method: 'post', diff --git a/examples/svelte-query/src/gen/hooks/updateUserQuery.ts b/examples/svelte-query/src/gen/hooks/updateUserQuery.ts index f40bac1df..aa557e812 100644 --- a/examples/svelte-query/src/gen/hooks/updateUserQuery.ts +++ b/examples/svelte-query/src/gen/hooks/updateUserQuery.ts @@ -24,31 +24,13 @@ type UpdateUser = { export function updateUserQuery( username: UpdateUserPathParams['username'], options: { - mutation?: CreateMutationOptions< - UpdateUser['response'], - UpdateUser['error'], - { - data: UpdateUser['request'] - } - > + mutation?: CreateMutationOptions client?: UpdateUser['client']['parameters'] } = {}, -): CreateMutationResult< - UpdateUser['response'], - UpdateUser['error'], - { - data: UpdateUser['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - UpdateUser['response'], - UpdateUser['error'], - { - data: UpdateUser['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'put', url: `/user/${username}`, diff --git a/examples/svelte-query/src/gen/hooks/uploadFileQuery.ts b/examples/svelte-query/src/gen/hooks/uploadFileQuery.ts index 00817bcf2..1a1e4284b 100644 --- a/examples/svelte-query/src/gen/hooks/uploadFileQuery.ts +++ b/examples/svelte-query/src/gen/hooks/uploadFileQuery.ts @@ -24,31 +24,13 @@ export function uploadFileQuery( petId: UploadFilePathParams['petId'], params?: UploadFile['queryParams'], options: { - mutation?: CreateMutationOptions< - UploadFile['response'], - UploadFile['error'], - { - data: UploadFile['request'] - } - > + mutation?: CreateMutationOptions client?: UploadFile['client']['parameters'] } = {}, -): CreateMutationResult< - UploadFile['response'], - UploadFile['error'], - { - data: UploadFile['request'] - } -> { +): CreateMutationResult { const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {} - return createMutation< - UploadFile['response'], - UploadFile['error'], - { - data: UploadFile['request'] - } - >({ - mutationFn: async ({ data }) => { + return createMutation({ + mutationFn: async (data) => { const res = await client({ method: 'post', url: `/pet/${petId}/uploadImage`, diff --git a/packages/core/src/utils/FunctionParams.test.ts b/packages/core/src/utils/FunctionParams.test.ts index 0e3b00c05..5ba988c64 100644 --- a/packages/core/src/utils/FunctionParams.test.ts +++ b/packages/core/src/utils/FunctionParams.test.ts @@ -91,4 +91,6 @@ describe('objectToParameters', () => { .toString(), ).toEqual('{ id, data }?: { id: Id, data: Data }, params: Params') }) + + test.todo('if static functionality works') }) diff --git a/packages/core/src/utils/FunctionParams.ts b/packages/core/src/utils/FunctionParams.ts index 69b01bcf8..d743f2e29 100644 --- a/packages/core/src/utils/FunctionParams.ts +++ b/packages/core/src/utils/FunctionParams.ts @@ -57,7 +57,7 @@ export class FunctionParams { return this } - #orderItems(items: Array) { + static #orderItems(items: Array) { return orderBy(items.filter(Boolean), [ (v) => { if (Array.isArray(v)) { @@ -106,7 +106,7 @@ export class FunctionParams { return acc } - static #convertToObject(items: FunctionParamsAST[]): FunctionParamsAST { + static toObject(items: FunctionParamsAST[]): FunctionParamsAST { let type: string[] = [] let name: string[] = [] @@ -128,18 +128,14 @@ export class FunctionParams { } } - static toObject(item: FunctionParamsAST[]): FunctionParamsAST { - return FunctionParams.#convertToObject(item) - } - - toString(): string { - const sortedData = this.#orderItems(this.#items) + static toString(items: (FunctionParamsAST | FunctionParamsAST[])[]): string { + const sortedData = this.#orderItems(items) return sortedData .reduce((acc, item) => { if (Array.isArray(item)) { const subItems = this.#orderItems(item) as FunctionParamsAST[] - const objectItem = FunctionParams.#convertToObject(subItems) + const objectItem = FunctionParams.toObject(subItems) return FunctionParams.#addParams(acc, objectItem) } @@ -148,4 +144,16 @@ export class FunctionParams { }, [] as string[]) .join(', ') } + + toObject(): FunctionParamsAST { + const items = FunctionParams.#orderItems(this.#items).flat() + + return FunctionParams.toObject(items) + } + + toString(): string { + const items = FunctionParams.#orderItems(this.#items) + + return FunctionParams.toString(items) + } } diff --git a/packages/swagger-tanstack-query/src/components/Mutation.tsx b/packages/swagger-tanstack-query/src/components/Mutation.tsx index dd6c32e48..81ae244ea 100644 --- a/packages/swagger-tanstack-query/src/components/Mutation.tsx +++ b/packages/swagger-tanstack-query/src/components/Mutation.tsx @@ -271,9 +271,9 @@ export function Mutation({ const params = new FunctionParams() const mutateParams = new FunctionParams() - const requestType = FunctionParams.toObject( - mutate?.variablesType === 'mutate' - ? [ + const requestType = mutate?.variablesType === 'mutate' + ? FunctionParams.toObject( + [ ...getASTParams(schemas.pathParams, { typed: true }), { name: 'params', @@ -293,22 +293,11 @@ export function Mutation({ enabled: !!schemas.request?.name, required: isRequired(schemas.request?.schema), }, - ] - : [ - { - name: 'data', - type: `${factory.name}['request']`, - enabled: !!schemas.request?.name, - required: true, - }, - { - name: 'data', - type: `${factory.name}['request']`, - enabled: !schemas.request?.name, - required: true, - }, ], - )?.type + )?.type + : schemas.request?.name + ? `${factory.name}['request']` + : 'never' const client = { method: operation.method, @@ -335,7 +324,7 @@ export function Mutation({ const resultGenerics = [ `${factory.name}["response"]`, `${factory.name}["error"]`, - requestType, + mutate?.variablesType === 'mutate' ? requestType : `${factory.name}["request"]`, ] if (mutate?.variablesType === 'mutate') { @@ -397,7 +386,7 @@ export function Mutation({ mutateParams.add([ { - name: '{ data }', + name: 'data', enabled: !!schemas.request?.name, required: isRequired(schemas.request?.schema), },