From 5ab74a313594539880a15adcebad46cf49003aa2 Mon Sep 17 00:00:00 2001 From: Olzhas Alexandrov <9992724+o-alexandrov@users.noreply.github.com> Date: Tue, 19 Dec 2023 13:09:16 -0600 Subject: [PATCH] fix: auto-formatting regression (#1117) Signed-off-by: Olzhas Alexandrov <9992724+o-alexandrov@users.noreply.github.com> --- .../api/endpoints/petstoreFromFileSpec.ts | 64 +++---- .../petstoreFromFileSpecWithConfig.ts | 64 +++---- .../petstoreFromFileSpecWithTransformer.ts | 168 ++++++++---------- samples/basic/api/model/index.ts | 2 +- samples/basic/api/model/listPetsParams.ts | 8 +- .../basic/src/api/model/catType.ts | 2 +- .../basic/src/api/model/dachshundBreed.ts | 3 +- .../basic/src/api/model/dogType.ts | 2 +- .../basic/src/api/model/labradoodleBreed.ts | 2 +- .../basic/src/api/model/petCallingCode.ts | 3 +- .../basic/src/api/model/petCountry.ts | 2 +- .../src/api/model/petCallingCode.ts | 3 +- .../custom-client/src/api/model/petCountry.ts | 2 +- .../models/petCallingCode.ts | 3 +- .../form-data-mutator/models/petCountry.ts | 2 +- .../form-data/models/petCallingCode.ts | 3 +- .../form-data/models/petCountry.ts | 2 +- .../models/petCallingCode.ts | 3 +- .../models/petCountry.ts | 2 +- .../react-query/form-url-encoded/endpoints.ts | 131 +++++++------- .../form-url-encoded/models/index.ts | 2 +- .../form-url-encoded/models/petCallingCode.ts | 1 - .../form-url-encoded/models/petCountry.ts | 3 +- .../hook-mutator/models/petCallingCode.ts | 3 +- .../hook-mutator/models/petCountry.ts | 2 +- 25 files changed, 215 insertions(+), 267 deletions(-) diff --git a/samples/basic/api/endpoints/petstoreFromFileSpec.ts b/samples/basic/api/endpoints/petstoreFromFileSpec.ts index 19f8421be..b77d566f1 100644 --- a/samples/basic/api/endpoints/petstoreFromFileSpec.ts +++ b/samples/basic/api/endpoints/petstoreFromFileSpec.ts @@ -4,21 +4,18 @@ * Swagger Petstore * OpenAPI spec version: 1.0.0 */ -import axios from 'axios' -import type { - AxiosRequestConfig, - AxiosResponse -} from 'axios' +import axios from 'axios'; +import type { AxiosRequestConfig, AxiosResponse } from 'axios'; export type CreatePetsBody = { name: string; tag: string; }; export type ListPetsParams = { -/** - * How many items to return at one time (max 100) - */ -limit?: string; + /** + * How many items to return at one time (max 100) + */ + limit?: string; }; export interface Error { @@ -34,46 +31,39 @@ export interface Pet { export type Pets = Pet[]; - - - - - /** +/** * @summary List all pets */ export const listPets = >( - params?: ListPetsParams, options?: AxiosRequestConfig - ): Promise => { - return axios.get( - `/pets`,{ + params?: ListPetsParams, + options?: AxiosRequestConfig, +): Promise => { + return axios.get(`/pets`, { ...options, - params: {...params, ...options?.params},} - ); - } + params: { ...params, ...options?.params }, + }); +}; /** * @summary Create a pet */ export const createPets = >( - createPetsBody: CreatePetsBody, options?: AxiosRequestConfig - ): Promise => { - return axios.post( - `/pets`, - createPetsBody,options - ); - } + createPetsBody: CreatePetsBody, + options?: AxiosRequestConfig, +): Promise => { + return axios.post(`/pets`, createPetsBody, options); +}; /** * @summary Info for a specific pet */ export const showPetById = >( - petId: string, options?: AxiosRequestConfig - ): Promise => { - return axios.get( - `/pets/${petId}`,options - ); - } + petId: string, + options?: AxiosRequestConfig, +): Promise => { + return axios.get(`/pets/${petId}`, options); +}; -export type ListPetsResult = AxiosResponse -export type CreatePetsResult = AxiosResponse -export type ShowPetByIdResult = AxiosResponse +export type ListPetsResult = AxiosResponse; +export type CreatePetsResult = AxiosResponse; +export type ShowPetByIdResult = AxiosResponse; diff --git a/samples/basic/api/endpoints/petstoreFromFileSpecWithConfig.ts b/samples/basic/api/endpoints/petstoreFromFileSpecWithConfig.ts index 19f8421be..b77d566f1 100644 --- a/samples/basic/api/endpoints/petstoreFromFileSpecWithConfig.ts +++ b/samples/basic/api/endpoints/petstoreFromFileSpecWithConfig.ts @@ -4,21 +4,18 @@ * Swagger Petstore * OpenAPI spec version: 1.0.0 */ -import axios from 'axios' -import type { - AxiosRequestConfig, - AxiosResponse -} from 'axios' +import axios from 'axios'; +import type { AxiosRequestConfig, AxiosResponse } from 'axios'; export type CreatePetsBody = { name: string; tag: string; }; export type ListPetsParams = { -/** - * How many items to return at one time (max 100) - */ -limit?: string; + /** + * How many items to return at one time (max 100) + */ + limit?: string; }; export interface Error { @@ -34,46 +31,39 @@ export interface Pet { export type Pets = Pet[]; - - - - - /** +/** * @summary List all pets */ export const listPets = >( - params?: ListPetsParams, options?: AxiosRequestConfig - ): Promise => { - return axios.get( - `/pets`,{ + params?: ListPetsParams, + options?: AxiosRequestConfig, +): Promise => { + return axios.get(`/pets`, { ...options, - params: {...params, ...options?.params},} - ); - } + params: { ...params, ...options?.params }, + }); +}; /** * @summary Create a pet */ export const createPets = >( - createPetsBody: CreatePetsBody, options?: AxiosRequestConfig - ): Promise => { - return axios.post( - `/pets`, - createPetsBody,options - ); - } + createPetsBody: CreatePetsBody, + options?: AxiosRequestConfig, +): Promise => { + return axios.post(`/pets`, createPetsBody, options); +}; /** * @summary Info for a specific pet */ export const showPetById = >( - petId: string, options?: AxiosRequestConfig - ): Promise => { - return axios.get( - `/pets/${petId}`,options - ); - } + petId: string, + options?: AxiosRequestConfig, +): Promise => { + return axios.get(`/pets/${petId}`, options); +}; -export type ListPetsResult = AxiosResponse -export type CreatePetsResult = AxiosResponse -export type ShowPetByIdResult = AxiosResponse +export type ListPetsResult = AxiosResponse; +export type CreatePetsResult = AxiosResponse; +export type ShowPetByIdResult = AxiosResponse; diff --git a/samples/basic/api/endpoints/petstoreFromFileSpecWithTransformer.ts b/samples/basic/api/endpoints/petstoreFromFileSpecWithTransformer.ts index 95b757441..e8cd83964 100644 --- a/samples/basic/api/endpoints/petstoreFromFileSpecWithTransformer.ts +++ b/samples/basic/api/endpoints/petstoreFromFileSpecWithTransformer.ts @@ -4,119 +4,97 @@ * Swagger Petstore * OpenAPI spec version: 1.0.0 */ -import axios from 'axios' -import type { - AxiosRequestConfig, - AxiosResponse -} from 'axios' -import type { - CreatePetsBody, - ListPetsParams, - Pet, - Pets -} from '../model' -import { - faker -} from '@faker-js/faker' -import { - HttpResponse, - delay, - http -} from 'msw' +import axios from 'axios'; +import type { AxiosRequestConfig, AxiosResponse } from 'axios'; +import type { CreatePetsBody, ListPetsParams, Pet, Pets } from '../model'; +import { faker } from '@faker-js/faker'; +import { HttpResponse, delay, http } from 'msw'; import listPetsMutator from '../mutator/response-type'; - - - - /** +/** * @summary List all pets */ -export const listPets = ( - params?: ListPetsParams, - version: number = 1, - ) => { - return listPetsMutator( - {url: `/v${version}/pets`, method: 'GET', - params - }, - ); - } - +export const listPets = (params?: ListPetsParams, version: number = 1) => { + return listPetsMutator({ + url: `/v${version}/pets`, + method: 'GET', + params, + }); +}; + /** * @summary Create a pet */ export const createPets = >( - createPetsBody: CreatePetsBody, - version: number = 1, options?: AxiosRequestConfig - ): Promise => { - return axios.post( - `/v${version}/pets`, - createPetsBody,options - ); - } + createPetsBody: CreatePetsBody, + version: number = 1, + options?: AxiosRequestConfig, +): Promise => { + return axios.post(`/v${version}/pets`, createPetsBody, options); +}; /** * @summary Info for a specific pet */ export const showPetById = >( - petId: string, - version: number = 1, options?: AxiosRequestConfig - ): Promise => { - return axios.get( - `/v${version}/pets/${petId}`,options - ); - } - + petId: string, + version: number = 1, + options?: AxiosRequestConfig, +): Promise => { + return axios.get(`/v${version}/pets/${petId}`, options); +}; type AwaitedInput = PromiseLike | T; - type Awaited = O extends AwaitedInput ? T : never; - -export type ListPetsResult = NonNullable>> -export type CreatePetsResult = AxiosResponse -export type ShowPetByIdResult = AxiosResponse +type Awaited = O extends AwaitedInput ? T : never; +export type ListPetsResult = NonNullable>>; +export type CreatePetsResult = AxiosResponse; +export type ShowPetByIdResult = AxiosResponse; -export const getListPetsMock = () => (Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({id: faker.number.int({min: undefined, max: undefined}), name: 'jon', tag: 'jon'}))) +export const getListPetsMock = () => + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => ({ + id: faker.number.int({ min: undefined, max: undefined }), + name: 'jon', + tag: 'jon', + })); -export const getShowPetByIdMock = () => ((() => ({ - id: faker.number.int({ min: 1, max: 99 }), - name: faker.person.firstName(), - tag: faker.helpers.arrayElement([ - faker.word.sample(), - void 0 - ]) - }))()) +export const getShowPetByIdMock = () => + (() => ({ + id: faker.number.int({ min: 1, max: 99 }), + name: faker.person.firstName(), + tag: faker.helpers.arrayElement([faker.word.sample(), void 0]), + }))(); export const getSwaggerPetstoreMock = () => [ -http.get('*/v:version/pets', async () => { - await delay(1000); - return new HttpResponse(JSON.stringify(getListPetsMock()), - { - status: 200, - headers: { - 'Content-Type': 'application/json', - } - } - ) - }),http.post('*/v:version/pets', async () => { - await delay(1000); - return new HttpResponse(null, - { - status: 200, - headers: { - 'Content-Type': 'application/json', - } - } - ) - }),http.get('*/v:version/pets/:petId', async () => { - await delay(1000); - return new HttpResponse(JSON.stringify(getShowPetByIdMock()), - { - status: 200, - headers: { - 'Content-Type': 'application/json', - } - } - ) - }),] + http.get('*/v:version/pets', async () => { + await delay(1000); + return new HttpResponse(JSON.stringify(getListPetsMock()), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); + }), + http.post('*/v:version/pets', async () => { + await delay(1000); + return new HttpResponse(null, { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); + }), + http.get('*/v:version/pets/:petId', async () => { + await delay(1000); + return new HttpResponse(JSON.stringify(getShowPetByIdMock()), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); + }), +]; diff --git a/samples/basic/api/model/index.ts b/samples/basic/api/model/index.ts index 12ceb51cd..ae1737fd1 100644 --- a/samples/basic/api/model/index.ts +++ b/samples/basic/api/model/index.ts @@ -9,4 +9,4 @@ export * from './createPetsBody'; export * from './error'; export * from './listPetsParams'; export * from './pet'; -export * from './pets'; \ No newline at end of file +export * from './pets'; diff --git a/samples/basic/api/model/listPetsParams.ts b/samples/basic/api/model/listPetsParams.ts index ac2092b96..8104138bb 100644 --- a/samples/basic/api/model/listPetsParams.ts +++ b/samples/basic/api/model/listPetsParams.ts @@ -6,8 +6,8 @@ */ export type ListPetsParams = { -/** - * How many items to return at one time (max 100) - */ -limit?: string; + /** + * How many items to return at one time (max 100) + */ + limit?: string; }; diff --git a/samples/react-query/basic/src/api/model/catType.ts b/samples/react-query/basic/src/api/model/catType.ts index 10d29fafd..c2968e98c 100644 --- a/samples/react-query/basic/src/api/model/catType.ts +++ b/samples/react-query/basic/src/api/model/catType.ts @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type CatType = (typeof CatType)[keyof typeof CatType]; +export type CatType = typeof CatType[keyof typeof CatType]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const CatType = { diff --git a/samples/react-query/basic/src/api/model/dachshundBreed.ts b/samples/react-query/basic/src/api/model/dachshundBreed.ts index 432c5c586..1527f519a 100644 --- a/samples/react-query/basic/src/api/model/dachshundBreed.ts +++ b/samples/react-query/basic/src/api/model/dachshundBreed.ts @@ -5,8 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type DachshundBreed = - (typeof DachshundBreed)[keyof typeof DachshundBreed]; +export type DachshundBreed = typeof DachshundBreed[keyof typeof DachshundBreed]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const DachshundBreed = { diff --git a/samples/react-query/basic/src/api/model/dogType.ts b/samples/react-query/basic/src/api/model/dogType.ts index 9ec97fcbd..3ef95fffb 100644 --- a/samples/react-query/basic/src/api/model/dogType.ts +++ b/samples/react-query/basic/src/api/model/dogType.ts @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type DogType = (typeof DogType)[keyof typeof DogType]; +export type DogType = typeof DogType[keyof typeof DogType]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const DogType = { diff --git a/samples/react-query/basic/src/api/model/labradoodleBreed.ts b/samples/react-query/basic/src/api/model/labradoodleBreed.ts index 5ad93d70c..c76cd923f 100644 --- a/samples/react-query/basic/src/api/model/labradoodleBreed.ts +++ b/samples/react-query/basic/src/api/model/labradoodleBreed.ts @@ -6,7 +6,7 @@ */ export type LabradoodleBreed = - (typeof LabradoodleBreed)[keyof typeof LabradoodleBreed]; + typeof LabradoodleBreed[keyof typeof LabradoodleBreed]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const LabradoodleBreed = { diff --git a/samples/react-query/basic/src/api/model/petCallingCode.ts b/samples/react-query/basic/src/api/model/petCallingCode.ts index cf8e6d305..1bfb9bec2 100644 --- a/samples/react-query/basic/src/api/model/petCallingCode.ts +++ b/samples/react-query/basic/src/api/model/petCallingCode.ts @@ -5,8 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type PetCallingCode = - (typeof PetCallingCode)[keyof typeof PetCallingCode]; +export type PetCallingCode = typeof PetCallingCode[keyof typeof PetCallingCode]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCallingCode = { diff --git a/samples/react-query/basic/src/api/model/petCountry.ts b/samples/react-query/basic/src/api/model/petCountry.ts index 35820be1d..e0152c3b7 100644 --- a/samples/react-query/basic/src/api/model/petCountry.ts +++ b/samples/react-query/basic/src/api/model/petCountry.ts @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type PetCountry = (typeof PetCountry)[keyof typeof PetCountry]; +export type PetCountry = typeof PetCountry[keyof typeof PetCountry]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCountry = { diff --git a/samples/react-query/custom-client/src/api/model/petCallingCode.ts b/samples/react-query/custom-client/src/api/model/petCallingCode.ts index cf8e6d305..1bfb9bec2 100644 --- a/samples/react-query/custom-client/src/api/model/petCallingCode.ts +++ b/samples/react-query/custom-client/src/api/model/petCallingCode.ts @@ -5,8 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type PetCallingCode = - (typeof PetCallingCode)[keyof typeof PetCallingCode]; +export type PetCallingCode = typeof PetCallingCode[keyof typeof PetCallingCode]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCallingCode = { diff --git a/samples/react-query/custom-client/src/api/model/petCountry.ts b/samples/react-query/custom-client/src/api/model/petCountry.ts index 35820be1d..e0152c3b7 100644 --- a/samples/react-query/custom-client/src/api/model/petCountry.ts +++ b/samples/react-query/custom-client/src/api/model/petCountry.ts @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type PetCountry = (typeof PetCountry)[keyof typeof PetCountry]; +export type PetCountry = typeof PetCountry[keyof typeof PetCountry]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCountry = { diff --git a/samples/react-query/form-data-mutator/models/petCallingCode.ts b/samples/react-query/form-data-mutator/models/petCallingCode.ts index cf8e6d305..1bfb9bec2 100644 --- a/samples/react-query/form-data-mutator/models/petCallingCode.ts +++ b/samples/react-query/form-data-mutator/models/petCallingCode.ts @@ -5,8 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type PetCallingCode = - (typeof PetCallingCode)[keyof typeof PetCallingCode]; +export type PetCallingCode = typeof PetCallingCode[keyof typeof PetCallingCode]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCallingCode = { diff --git a/samples/react-query/form-data-mutator/models/petCountry.ts b/samples/react-query/form-data-mutator/models/petCountry.ts index 35820be1d..e0152c3b7 100644 --- a/samples/react-query/form-data-mutator/models/petCountry.ts +++ b/samples/react-query/form-data-mutator/models/petCountry.ts @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type PetCountry = (typeof PetCountry)[keyof typeof PetCountry]; +export type PetCountry = typeof PetCountry[keyof typeof PetCountry]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCountry = { diff --git a/samples/react-query/form-data/models/petCallingCode.ts b/samples/react-query/form-data/models/petCallingCode.ts index cf8e6d305..1bfb9bec2 100644 --- a/samples/react-query/form-data/models/petCallingCode.ts +++ b/samples/react-query/form-data/models/petCallingCode.ts @@ -5,8 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type PetCallingCode = - (typeof PetCallingCode)[keyof typeof PetCallingCode]; +export type PetCallingCode = typeof PetCallingCode[keyof typeof PetCallingCode]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCallingCode = { diff --git a/samples/react-query/form-data/models/petCountry.ts b/samples/react-query/form-data/models/petCountry.ts index 35820be1d..e0152c3b7 100644 --- a/samples/react-query/form-data/models/petCountry.ts +++ b/samples/react-query/form-data/models/petCountry.ts @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type PetCountry = (typeof PetCountry)[keyof typeof PetCountry]; +export type PetCountry = typeof PetCountry[keyof typeof PetCountry]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCountry = { diff --git a/samples/react-query/form-url-encoded-mutator/models/petCallingCode.ts b/samples/react-query/form-url-encoded-mutator/models/petCallingCode.ts index cf8e6d305..1bfb9bec2 100644 --- a/samples/react-query/form-url-encoded-mutator/models/petCallingCode.ts +++ b/samples/react-query/form-url-encoded-mutator/models/petCallingCode.ts @@ -5,8 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type PetCallingCode = - (typeof PetCallingCode)[keyof typeof PetCallingCode]; +export type PetCallingCode = typeof PetCallingCode[keyof typeof PetCallingCode]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCallingCode = { diff --git a/samples/react-query/form-url-encoded-mutator/models/petCountry.ts b/samples/react-query/form-url-encoded-mutator/models/petCountry.ts index 35820be1d..e0152c3b7 100644 --- a/samples/react-query/form-url-encoded-mutator/models/petCountry.ts +++ b/samples/react-query/form-url-encoded-mutator/models/petCountry.ts @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type PetCountry = (typeof PetCountry)[keyof typeof PetCountry]; +export type PetCountry = typeof PetCountry[keyof typeof PetCountry]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCountry = { diff --git a/samples/react-query/form-url-encoded/endpoints.ts b/samples/react-query/form-url-encoded/endpoints.ts index 21cd888ee..ed6806ee3 100644 --- a/samples/react-query/form-url-encoded/endpoints.ts +++ b/samples/react-query/form-url-encoded/endpoints.ts @@ -4,80 +4,79 @@ * Swagger Petstore * OpenAPI spec version: 1.0.0 */ -import { - useMutation -} from 'react-query' -import type { - MutationFunction, - UseMutationOptions -} from 'react-query' -import type { - CreatePetsBody, - Error, - Pet -} from './models' +import { useMutation } from 'react-query'; +import type { MutationFunction, UseMutationOptions } from 'react-query'; +import type { CreatePetsBody, Error, Pet } from './models'; import { customInstance } from './custom-instance'; - type AwaitedInput = PromiseLike | T; - type Awaited = O extends AwaitedInput ? T : never; - - +type Awaited = O extends AwaitedInput ? T : never; /** * @summary Create a pet */ -export const createPets = ( - createPetsBody: CreatePetsBody, - ) => { - - const formUrlEncoded = new URLSearchParams(); -formUrlEncoded.append('name', createPetsBody.name) -formUrlEncoded.append('tag', createPetsBody.tag) - - return customInstance( - {url: `/pets`, method: 'POST', - headers: {'Content-Type': 'application/x-www-form-urlencoded', }, - data: formUrlEncoded - }, - ); - } - - - -export const getCreatePetsMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{data: CreatePetsBody}, TContext>, } -): UseMutationOptions>, TError,{data: CreatePetsBody}, TContext> => { - const {mutation: mutationOptions} = options ?? {}; - - - - - const mutationFn: MutationFunction>, {data: CreatePetsBody}> = (props) => { - const {data} = props ?? {}; +export const createPets = (createPetsBody: CreatePetsBody) => { + const formUrlEncoded = new URLSearchParams(); + formUrlEncoded.append('name', createPetsBody.name); + formUrlEncoded.append('tag', createPetsBody.tag); + + return customInstance({ + url: `/pets`, + method: 'POST', + headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, + data: formUrlEncoded, + }); +}; + +export const getCreatePetsMutationOptions = < + TError = Error, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CreatePetsBody }, + TContext + >; +}): UseMutationOptions< + Awaited>, + TError, + { data: CreatePetsBody }, + TContext +> => { + const { mutation: mutationOptions } = options ?? {}; + + const mutationFn: MutationFunction< + Awaited>, + { data: CreatePetsBody } + > = (props) => { + const { data } = props ?? {}; + + return createPets(data); + }; + + return { mutationFn, ...mutationOptions }; +}; + +export type CreatePetsMutationResult = NonNullable< + Awaited> +>; +export type CreatePetsMutationBody = CreatePetsBody; +export type CreatePetsMutationError = Error; - return createPets(data,) - } - - - - - return { mutationFn, ...mutationOptions }} - - export type CreatePetsMutationResult = NonNullable>> - export type CreatePetsMutationBody = CreatePetsBody - export type CreatePetsMutationError = Error - - /** +/** * @summary Create a pet */ -export const useCreatePets = (options?: { mutation?:UseMutationOptions>, TError,{data: CreatePetsBody}, TContext>, } -) => { - - const mutationOptions = getCreatePetsMutationOptions(options); - - return useMutation(mutationOptions); - } - +export const useCreatePets = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CreatePetsBody }, + TContext + >; +}) => { + const mutationOptions = getCreatePetsMutationOptions(options); + + return useMutation(mutationOptions); +}; diff --git a/samples/react-query/form-url-encoded/models/index.ts b/samples/react-query/form-url-encoded/models/index.ts index 4a369c610..032cef6c1 100644 --- a/samples/react-query/form-url-encoded/models/index.ts +++ b/samples/react-query/form-url-encoded/models/index.ts @@ -9,4 +9,4 @@ export * from './createPetsBody'; export * from './error'; export * from './pet'; export * from './petCallingCode'; -export * from './petCountry'; \ No newline at end of file +export * from './petCountry'; diff --git a/samples/react-query/form-url-encoded/models/petCallingCode.ts b/samples/react-query/form-url-encoded/models/petCallingCode.ts index d222d14bd..1bfb9bec2 100644 --- a/samples/react-query/form-url-encoded/models/petCallingCode.ts +++ b/samples/react-query/form-url-encoded/models/petCallingCode.ts @@ -7,7 +7,6 @@ export type PetCallingCode = typeof PetCallingCode[keyof typeof PetCallingCode]; - // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCallingCode = { '+33': '+33', diff --git a/samples/react-query/form-url-encoded/models/petCountry.ts b/samples/react-query/form-url-encoded/models/petCountry.ts index 460a96901..e0152c3b7 100644 --- a/samples/react-query/form-url-encoded/models/petCountry.ts +++ b/samples/react-query/form-url-encoded/models/petCountry.ts @@ -7,9 +7,8 @@ export type PetCountry = typeof PetCountry[keyof typeof PetCountry]; - // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCountry = { - 'People\'s_Republic_of_China': 'People\'s Republic of China', + "People's_Republic_of_China": "People's Republic of China", Uruguay: 'Uruguay', } as const; diff --git a/samples/react-query/hook-mutator/models/petCallingCode.ts b/samples/react-query/hook-mutator/models/petCallingCode.ts index cf8e6d305..1bfb9bec2 100644 --- a/samples/react-query/hook-mutator/models/petCallingCode.ts +++ b/samples/react-query/hook-mutator/models/petCallingCode.ts @@ -5,8 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type PetCallingCode = - (typeof PetCallingCode)[keyof typeof PetCallingCode]; +export type PetCallingCode = typeof PetCallingCode[keyof typeof PetCallingCode]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCallingCode = { diff --git a/samples/react-query/hook-mutator/models/petCountry.ts b/samples/react-query/hook-mutator/models/petCountry.ts index 35820be1d..e0152c3b7 100644 --- a/samples/react-query/hook-mutator/models/petCountry.ts +++ b/samples/react-query/hook-mutator/models/petCountry.ts @@ -5,7 +5,7 @@ * OpenAPI spec version: 1.0.0 */ -export type PetCountry = (typeof PetCountry)[keyof typeof PetCountry]; +export type PetCountry = typeof PetCountry[keyof typeof PetCountry]; // eslint-disable-next-line @typescript-eslint/no-redeclare export const PetCountry = {