From 63fe9650ab0755fe5a4d1449fd0ef2b24cc78532 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Bansal Date: Wed, 13 May 2020 17:50:15 +0530 Subject: [PATCH] feat: add support for path params is useMutate --- src/Get.tsx | 18 +-- src/Mutate.tsx | 12 +- src/Poll.tsx | 18 +-- src/scripts/import-open-api.ts | 12 +- .../import-open-api.test.ts.snap | 30 ++--- src/scripts/tests/import-open-api.test.ts | 112 +++++++++--------- 6 files changed, 107 insertions(+), 95 deletions(-) diff --git a/src/Get.tsx b/src/Get.tsx index 193953f0..ea76b449 100644 --- a/src/Get.tsx +++ b/src/Get.tsx @@ -57,7 +57,7 @@ export interface Meta { /** * Props for the component. */ -export interface GetProps { +export interface GetProps { /** * The path at which to request data, * typically composed by parent Gets or the RestfulProvider. @@ -78,6 +78,10 @@ export interface GetProps { children: (data: TData | null, states: States, actions: Actions, meta: Meta) => React.ReactNode; /** Options passed into the fetch call. */ requestOptions?: RestfulReactProviderProps["requestOptions"]; + /** + * Query parameters + */ + pathParams?: TPathParams; /** * Query parameters */ @@ -142,11 +146,11 @@ export interface GetState { * is a named class because it is useful in * debugging. */ -class ContextlessGet extends React.Component< - GetProps & InjectedProps, +class ContextlessGet extends React.Component< + GetProps & InjectedProps, Readonly> > { - constructor(props: GetProps & InjectedProps) { + constructor(props: GetProps & InjectedProps) { super(props); if (typeof props.debounce === "object") { @@ -184,7 +188,7 @@ class ContextlessGet extends React.Component< } } - public componentDidUpdate(prevProps: GetProps) { + public componentDidUpdate(prevProps: GetProps) { const { base, parentPath, path, resolve, queryParams } = prevProps; if ( base !== this.props.base || @@ -335,8 +339,8 @@ class ContextlessGet extends React.Component< * in order to provide new `parentPath` props that contain * a segment of the path, creating composable URLs. */ -function Get( - props: GetProps, +function Get( + props: GetProps, ) { return ( diff --git a/src/Mutate.tsx b/src/Mutate.tsx index 521b50b3..a9d9e621 100644 --- a/src/Mutate.tsx +++ b/src/Mutate.tsx @@ -44,7 +44,7 @@ export interface Meta { /** * Props for the component. */ -export interface MutateProps { +export interface MutateProps { /** * The path at which to request data, * typically composed by parents or the RestfulProvider. @@ -268,9 +268,13 @@ class ContextlessMutate( - props: MutateProps, -) { +function Mutate< + TData = any, + TError = any, + TQueryParams = { [key: string]: any }, + TRequestBody = any, + TPathParams = unknown +>(props: MutateProps) { return ( {contextProps => ( diff --git a/src/Poll.tsx b/src/Poll.tsx index f9f60e61..d29ccc0d 100644 --- a/src/Poll.tsx +++ b/src/Poll.tsx @@ -52,11 +52,11 @@ interface Actions { /** * Props that can control the Poll component. */ -export interface PollProps { +export interface PollProps { /** * What path are we polling on? */ - path: GetProps["path"]; + path: GetProps["path"]; /** * A function that gets polled data, the current * states, meta information, and various actions @@ -89,7 +89,7 @@ export interface PollProps { * Are we going to wait to start the poll? * Use this with { start, stop } actions. */ - lazy?: GetProps["lazy"]; + lazy?: GetProps["lazy"]; /** * Should the data be transformed in any way? */ @@ -97,11 +97,11 @@ export interface PollProps { /** * We can request foreign URLs with this prop. */ - base?: GetProps["base"]; + base?: GetProps["base"]; /** * Any options to be passed to this request. */ - requestOptions?: GetProps["requestOptions"]; + requestOptions?: GetProps["requestOptions"]; /** * Query parameters */ @@ -155,8 +155,8 @@ export interface PollState { /** * The component without context. */ -class ContextlessPoll extends React.Component< - PollProps & InjectedProps, +class ContextlessPoll extends React.Component< + PollProps & InjectedProps, Readonly> > { public readonly state: Readonly> = { @@ -339,8 +339,8 @@ class ContextlessPoll extends React.Component< } } -function Poll( - props: PollProps, +function Poll( + props: PollProps, ) { // Compose Contexts to allow for URL nesting return ( diff --git a/src/scripts/import-open-api.ts b/src/scripts/import-open-api.ts index 1c9d74eb..56213f79 100644 --- a/src/scripts/import-open-api.ts +++ b/src/scripts/import-open-api.ts @@ -384,7 +384,7 @@ export const generateRestfulComponent = ( verb === "get" ? `${needAResponseComponent ? componentName + "Response" : responseTypes}, ${errorTypes}, ${ queryParamsType ? componentName + "QueryParams" : "void" - }` + }, ${paramsInPath.length ? componentName + "PathParams" : "void"}` : `${needAResponseComponent ? componentName + "Response" : responseTypes}, ${errorTypes}, ${ queryParamsType ? componentName + "QueryParams" : "void" }, ${ @@ -393,7 +393,7 @@ export const generateRestfulComponent = ( : needARequestBodyComponent ? componentName + "RequestBody" : requestBodyTypes - }`; + }, ${paramsInPath.length ? componentName + "PathParams" : "void"}`; const genericsTypesForHooksProps = verb === "get" @@ -451,7 +451,7 @@ export interface ${componentName}RequestBody ${requestBodyTypes} } export type ${componentName}Props = Omit<${Component}Props<${genericsTypes}>, "path"${ verb === "get" ? "" : ` | "verb"` - }>${paramsInPath.length ? ` & {${paramsTypes}}` : ""}; + }>${paramsInPath.length ? ` & ${componentName}PathParams` : ""}; ${description}export const ${componentName} = (${ paramsInPath.length ? `{${paramsInPath.join(", ")}, ...props}` : "props" @@ -482,7 +482,11 @@ ${description}export const use${componentName} = (${ paramsInPath.length ? `{${paramsInPath.join(", ")}, ...props}` : "props" }: Use${componentName}Props) => use${Component}<${genericsTypes}>(${ verb === "get" ? "" : `"${verb.toUpperCase()}", ` - }${paramsInPath.length ? `({ ${paramsInPath.join(", ")} }) => \`${route}\`` : `\`${route}\``}, { ${ + }${ + paramsInPath.length + ? `({ ${paramsInPath.join(", ")} }: ${componentName}PathParams) => \`${route}\`` + : `\`${route}\`` + }, { ${ customPropsEntries.length ? `{ ${customPropsEntries .map(([key, value]) => `${key}:${reactPropsValueToObjectValue(value || "")}`) diff --git a/src/scripts/tests/__snapshots__/import-open-api.test.ts.snap b/src/scripts/tests/__snapshots__/import-open-api.test.ts.snap index 499ebe9f..a7e63ba0 100644 --- a/src/scripts/tests/__snapshots__/import-open-api.test.ts.snap +++ b/src/scripts/tests/__snapshots__/import-open-api.test.ts.snap @@ -72,7 +72,7 @@ export interface FindPetsQueryParams { limit?: number; } -export type FindPetsProps = Omit, \\"path\\">; +export type FindPetsProps = Omit, \\"path\\">; /** * Returns all pets from the system that the user has access to @@ -82,7 +82,7 @@ export type FindPetsProps = Omit, \\ * */ export const FindPets = (props: FindPetsProps) => ( - + path={\`/pets\`} {...props} /> @@ -97,16 +97,16 @@ export type UseFindPetsProps = Omit useGet(\`/pets\`, { ...props }); +export const useFindPets = (props: UseFindPetsProps) => useGet(\`/pets\`, { ...props }); -export type AddPetProps = Omit, \\"path\\" | \\"verb\\">; +export type AddPetProps = Omit, \\"path\\" | \\"verb\\">; /** * Creates a new pet in the store. Duplicates are allowed */ export const AddPet = (props: AddPetProps) => ( - + verb=\\"POST\\" path={\`/pets\`} {...props} @@ -118,20 +118,20 @@ export type UseAddPetProps = Omit, \\"pa /** * Creates a new pet in the store. Duplicates are allowed */ -export const useAddPet = (props: UseAddPetProps) => useMutate(\\"POST\\", \`/pets\`, { ...props }); +export const useAddPet = (props: UseAddPetProps) => useMutate(\\"POST\\", \`/pets\`, { ...props }); export interface FindPetByIdPathParams { id: number } -export type FindPetByIdProps = Omit, \\"path\\"> & {id: number}; +export type FindPetByIdProps = Omit, \\"path\\"> & FindPetByIdPathParams; /** * Returns a user based on a single ID, if the user does not have access to the pet */ export const FindPetById = ({id, ...props}: FindPetByIdProps) => ( - + path={\`/pets/\${id}\`} {...props} /> @@ -142,16 +142,16 @@ export type UseFindPetByIdProps = Omit useGet(({ id }) => \`/pets/\${id}\`, { pathParams: { id }, ...props }); +export const useFindPetById = ({id, ...props}: UseFindPetByIdProps) => useGet(({ id }: FindPetByIdPathParams) => \`/pets/\${id}\`, { pathParams: { id }, ...props }); -export type DeletePetProps = Omit, \\"path\\" | \\"verb\\">; +export type DeletePetProps = Omit, \\"path\\" | \\"verb\\">; /** * deletes a single pet based on the ID supplied */ export const DeletePet = (props: DeletePetProps) => ( - + verb=\\"DELETE\\" path={\`/pets\`} {...props} @@ -163,20 +163,20 @@ export type UseDeletePetProps = Omit, \ /** * deletes a single pet based on the ID supplied */ -export const useDeletePet = (props: UseDeletePetProps) => useMutate(\\"DELETE\\", \`/pets\`, { ...props }); +export const useDeletePet = (props: UseDeletePetProps) => useMutate(\\"DELETE\\", \`/pets\`, { ...props }); export interface UpdatePetPathParams { id: number } -export type UpdatePetProps = Omit, \\"path\\" | \\"verb\\"> & {id: number}; +export type UpdatePetProps = Omit, \\"path\\" | \\"verb\\"> & UpdatePetPathParams; /** * Updates a pet in the store. */ export const UpdatePet = ({id, ...props}: UpdatePetProps) => ( - + verb=\\"PATCH\\" path={\`/pets/\${id}\`} {...props} @@ -188,7 +188,7 @@ export type UseUpdatePetProps = Omit useMutate(\\"PATCH\\", ({ id }) => \`/pets/\${id}\`, { pathParams: { id }, ...props }); +export const useUpdatePet = ({id, ...props}: UseUpdatePetProps) => useMutate(\\"PATCH\\", ({ id }: UpdatePetPathParams) => \`/pets/\${id}\`, { pathParams: { id }, ...props }); " `; diff --git a/src/scripts/tests/import-open-api.test.ts b/src/scripts/tests/import-open-api.test.ts index e6697a64..7c83ec14 100644 --- a/src/scripts/tests/import-open-api.test.ts +++ b/src/scripts/tests/import-open-api.test.ts @@ -843,13 +843,13 @@ describe("scripts/import-open-api", () => { expect(generateRestfulComponent(operation, "get", "/fields", [])).toMatchInlineSnapshot(` " - export type ListFieldsProps = Omit, \\"path\\">; + export type ListFieldsProps = Omit, \\"path\\">; /** * List all fields for the use case schema */ export const ListFields = (props: ListFieldsProps) => ( - + path={\`/fields\`} {...props} /> @@ -860,7 +860,7 @@ describe("scripts/import-open-api", () => { /** * List all fields for the use case schema */ - export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); + export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); " `); @@ -882,7 +882,7 @@ describe("scripts/import-open-api", () => { expect(generateRestfulComponent(operation, "get", "/fields", [])).toMatchInlineSnapshot(` " - export type ListFieldsProps = Omit, \\"path\\">; + export type ListFieldsProps = Omit, \\"path\\">; /** * List all fields for the use case schema @@ -890,7 +890,7 @@ describe("scripts/import-open-api", () => { * This is a longer description to describe my endpoint */ export const ListFields = (props: ListFieldsProps) => ( - + path={\`/fields\`} {...props} /> @@ -903,7 +903,7 @@ describe("scripts/import-open-api", () => { * * This is a longer description to describe my endpoint */ - export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); + export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); " `); @@ -924,13 +924,13 @@ describe("scripts/import-open-api", () => { expect(generateRestfulComponent(operation, "get", "/fields", [])).toMatchInlineSnapshot(` " - export type ListFieldsProps = Omit, \\"path\\">; + export type ListFieldsProps = Omit, \\"path\\">; /** * List all fields for the use case schema */ export const ListFields = (props: ListFieldsProps) => ( - + path={\`/fields\`} {...props} /> @@ -941,7 +941,7 @@ describe("scripts/import-open-api", () => { /** * List all fields for the use case schema */ - export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); + export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); " `); @@ -975,13 +975,13 @@ describe("scripts/import-open-api", () => { expect(generateRestfulComponent(operation, "get", "/fields", [])).toMatchInlineSnapshot(` " - export type ListFieldsProps = Omit, \\"path\\">; + export type ListFieldsProps = Omit, \\"path\\">; /** * List all fields for the use case schema */ export const ListFields = (props: ListFieldsProps) => ( - + path={\`/fields\`} {...props} /> @@ -992,7 +992,7 @@ describe("scripts/import-open-api", () => { /** * List all fields for the use case schema */ - export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); + export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); " `); @@ -1052,13 +1052,13 @@ describe("scripts/import-open-api", () => { projectId?: string; } - export type ListFieldsProps = Omit, \\"path\\">; + export type ListFieldsProps = Omit, \\"path\\">; /** * List all fields for the use case schema */ export const ListFields = (props: ListFieldsProps) => ( - + path={\`/fields\`} {...props} /> @@ -1069,7 +1069,7 @@ describe("scripts/import-open-api", () => { /** * List all fields for the use case schema */ - export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); + export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); " `); @@ -1135,13 +1135,13 @@ describe("scripts/import-open-api", () => { projectId?: string; } - export type ListFieldsProps = Omit, \\"path\\">; + export type ListFieldsProps = Omit, \\"path\\">; /** * List all fields for the use case schema */ export const ListFields = (props: ListFieldsProps) => ( - + path={\`/fields\`} {...props} /> @@ -1152,7 +1152,7 @@ describe("scripts/import-open-api", () => { /** * List all fields for the use case schema */ - export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); + export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); " `); @@ -1206,13 +1206,13 @@ describe("scripts/import-open-api", () => { id: string } - export type ListFieldsProps = Omit, \\"path\\"> & {id: string}; + export type ListFieldsProps = Omit, \\"path\\"> & ListFieldsPathParams; /** * List all fields for the use case schema */ export const ListFields = ({id, ...props}: ListFieldsProps) => ( - + path={\`/fields/\${id}\`} {...props} /> @@ -1223,7 +1223,7 @@ describe("scripts/import-open-api", () => { /** * List all fields for the use case schema */ - export const useListFields = ({id, ...props}: UseListFieldsProps) => useGet(({ id }) => \`/fields/\${id}\`, { pathParams: { id }, ...props }); + export const useListFields = ({id, ...props}: UseListFieldsProps) => useGet(({ id }: ListFieldsPathParams) => \`/fields/\${id}\`, { pathParams: { id }, ...props }); " `); @@ -1284,13 +1284,13 @@ describe("scripts/import-open-api", () => { id: string } - export type ListFieldsProps = Omit, \\"path\\"> & {id: string}; + export type ListFieldsProps = Omit, \\"path\\"> & ListFieldsPathParams; /** * List all fields for the use case schema */ export const ListFields = ({id, ...props}: ListFieldsProps) => ( - + path={\`/fields/\${id}\`} {...props} /> @@ -1301,7 +1301,7 @@ describe("scripts/import-open-api", () => { /** * List all fields for the use case schema */ - export const useListFields = ({id, ...props}: UseListFieldsProps) => useGet(({ id }) => \`/fields/\${id}\`, { pathParams: { id }, ...props }); + export const useListFields = ({id, ...props}: UseListFieldsProps) => useGet(({ id }: ListFieldsPathParams) => \`/fields/\${id}\`, { pathParams: { id }, ...props }); " `); @@ -1355,13 +1355,13 @@ describe("scripts/import-open-api", () => { useCaseId: string } - export type UpdateUseCaseProps = Omit, \\"path\\" | \\"verb\\"> & {useCaseId: string}; + export type UpdateUseCaseProps = Omit, \\"path\\" | \\"verb\\"> & UpdateUseCasePathParams; /** * Update use case details */ export const UpdateUseCase = ({useCaseId, ...props}: UpdateUseCaseProps) => ( - + verb=\\"PUT\\" path={\`/use-cases/\${useCaseId}\`} {...props} @@ -1373,7 +1373,7 @@ describe("scripts/import-open-api", () => { /** * Update use case details */ - export const useUpdateUseCase = ({useCaseId, ...props}: UseUpdateUseCaseProps) => useMutate(\\"PUT\\", ({ useCaseId }) => \`/use-cases/\${useCaseId}\`, { pathParams: { useCaseId }, ...props }); + export const useUpdateUseCase = ({useCaseId, ...props}: UseUpdateUseCaseProps) => useMutate(\\"PUT\\", ({ useCaseId }: UpdateUseCasePathParams) => \`/use-cases/\${useCaseId}\`, { pathParams: { useCaseId }, ...props }); " `); @@ -1444,13 +1444,13 @@ describe("scripts/import-open-api", () => { description?: string; } - export type UpdateUseCaseProps = Omit, \\"path\\" | \\"verb\\"> & {useCaseId: string}; + export type UpdateUseCaseProps = Omit, \\"path\\" | \\"verb\\"> & UpdateUseCasePathParams; /** * Update use case details */ export const UpdateUseCase = ({useCaseId, ...props}: UpdateUseCaseProps) => ( - + verb=\\"PUT\\" path={\`/use-cases/\${useCaseId}\`} {...props} @@ -1462,7 +1462,7 @@ describe("scripts/import-open-api", () => { /** * Update use case details */ - export const useUpdateUseCase = ({useCaseId, ...props}: UseUpdateUseCaseProps) => useMutate(\\"PUT\\", ({ useCaseId }) => \`/use-cases/\${useCaseId}\`, { pathParams: { useCaseId }, ...props }); + export const useUpdateUseCase = ({useCaseId, ...props}: UseUpdateUseCaseProps) => useMutate(\\"PUT\\", ({ useCaseId }: UpdateUseCasePathParams) => \`/use-cases/\${useCaseId}\`, { pathParams: { useCaseId }, ...props }); " `); @@ -1536,13 +1536,13 @@ describe("scripts/import-open-api", () => { useCaseId: string } - export type UpdateUseCaseProps = Omit, \\"path\\" | \\"verb\\"> & {useCaseId: string}; + export type UpdateUseCaseProps = Omit, \\"path\\" | \\"verb\\"> & UpdateUseCasePathParams; /** * Update use case details */ export const UpdateUseCase = ({useCaseId, ...props}: UpdateUseCaseProps) => ( - + verb=\\"PUT\\" path={\`/use-cases/\${useCaseId}\`} {...props} @@ -1554,7 +1554,7 @@ describe("scripts/import-open-api", () => { /** * Update use case details */ - export const useUpdateUseCase = ({useCaseId, ...props}: UseUpdateUseCaseProps) => useMutate(\\"PUT\\", ({ useCaseId }) => \`/use-cases/\${useCaseId}\`, { pathParams: { useCaseId }, ...props }); + export const useUpdateUseCase = ({useCaseId, ...props}: UseUpdateUseCaseProps) => useMutate(\\"PUT\\", ({ useCaseId }: UpdateUseCasePathParams) => \`/use-cases/\${useCaseId}\`, { pathParams: { useCaseId }, ...props }); " `); @@ -1631,13 +1631,13 @@ describe("scripts/import-open-api", () => { useCaseId: string } - export type UpdateUseCaseProps = Omit, \\"path\\" | \\"verb\\"> & {useCaseId: string}; + export type UpdateUseCaseProps = Omit, \\"path\\" | \\"verb\\"> & UpdateUseCasePathParams; /** * Update use case details */ export const UpdateUseCase = ({useCaseId, ...props}: UpdateUseCaseProps) => ( - + verb=\\"PUT\\" path={\`/use-cases/\${useCaseId}\`} {...props} @@ -1649,7 +1649,7 @@ describe("scripts/import-open-api", () => { /** * Update use case details */ - export const useUpdateUseCase = ({useCaseId, ...props}: UseUpdateUseCaseProps) => useMutate(\\"PUT\\", ({ useCaseId }) => \`/use-cases/\${useCaseId}\`, { pathParams: { useCaseId }, ...props }); + export const useUpdateUseCase = ({useCaseId, ...props}: UseUpdateUseCaseProps) => useMutate(\\"PUT\\", ({ useCaseId }: UpdateUseCasePathParams) => \`/use-cases/\${useCaseId}\`, { pathParams: { useCaseId }, ...props }); " `); @@ -1694,13 +1694,13 @@ describe("scripts/import-open-api", () => { expect(generateRestfulComponent(operation, "delete", "/use-cases/{useCaseId}", [])).toMatchInlineSnapshot(` " - export type DeleteUseCaseProps = Omit, \\"path\\" | \\"verb\\">; + export type DeleteUseCaseProps = Omit, \\"path\\" | \\"verb\\">; /** * Delete use case */ export const DeleteUseCase = (props: DeleteUseCaseProps) => ( - + verb=\\"DELETE\\" path={\`/use-cases\`} {...props} @@ -1712,7 +1712,7 @@ describe("scripts/import-open-api", () => { /** * Delete use case */ - export const useDeleteUseCase = (props: UseDeleteUseCaseProps) => useMutate(\\"DELETE\\", \`/use-cases\`, { ...props }); + export const useDeleteUseCase = (props: UseDeleteUseCaseProps) => useMutate(\\"DELETE\\", \`/use-cases\`, { ...props }); " `); @@ -1760,13 +1760,13 @@ describe("scripts/import-open-api", () => { useCaseId: string } - export type DeleteUseCaseProps = Omit, \\"path\\" | \\"verb\\"> & {useCaseId: string}; + export type DeleteUseCaseProps = Omit, \\"path\\" | \\"verb\\"> & DeleteUseCasePathParams; /** * Delete use case */ export const DeleteUseCase = ({useCaseId, ...props}: DeleteUseCaseProps) => ( - + verb=\\"DELETE\\" path={\`/use-cases/\${useCaseId}/secret\`} {...props} @@ -1778,7 +1778,7 @@ describe("scripts/import-open-api", () => { /** * Delete use case */ - export const useDeleteUseCase = ({useCaseId, ...props}: UseDeleteUseCaseProps) => useMutate(\\"DELETE\\", ({ useCaseId }) => \`/use-cases/\${useCaseId}/secret\`, { pathParams: { useCaseId }, ...props }); + export const useDeleteUseCase = ({useCaseId, ...props}: UseDeleteUseCaseProps) => useMutate(\\"DELETE\\", ({ useCaseId }: DeleteUseCasePathParams) => \`/use-cases/\${useCaseId}/secret\`, { pathParams: { useCaseId }, ...props }); " `); @@ -1823,13 +1823,13 @@ describe("scripts/import-open-api", () => { expect(generateRestfulComponent(operation, "delete", "/use-cases/{useCaseId}", [])).toMatchInlineSnapshot(` " - export type DeleteUseCaseProps = Omit, \\"path\\" | \\"verb\\">; + export type DeleteUseCaseProps = Omit, \\"path\\" | \\"verb\\">; /** * Delete use case */ export const DeleteUseCase = (props: DeleteUseCaseProps) => ( - + verb=\\"DELETE\\" path={\`/use-cases\`} {...props} @@ -1841,7 +1841,7 @@ describe("scripts/import-open-api", () => { /** * Delete use case */ - export const useDeleteUseCase = (props: UseDeleteUseCaseProps) => useMutate(\\"DELETE\\", \`/use-cases\`, { ...props }); + export const useDeleteUseCase = (props: UseDeleteUseCaseProps) => useMutate(\\"DELETE\\", \`/use-cases\`, { ...props }); " `); @@ -1881,13 +1881,13 @@ describe("scripts/import-open-api", () => { expect(generateRestfulComponent(operation, "delete", "/use-cases/{useCaseId}", [])).toMatchInlineSnapshot(` " - export type DeleteUseCaseProps = Omit, \\"path\\" | \\"verb\\">; + export type DeleteUseCaseProps = Omit, \\"path\\" | \\"verb\\">; /** * Delete use case */ export const DeleteUseCase = (props: DeleteUseCaseProps) => ( - + verb=\\"DELETE\\" path={\`/use-cases\`} {...props} @@ -1899,7 +1899,7 @@ describe("scripts/import-open-api", () => { /** * Delete use case */ - export const useDeleteUseCase = (props: UseDeleteUseCaseProps) => useMutate(\\"DELETE\\", \`/use-cases\`, { ...props }); + export const useDeleteUseCase = (props: UseDeleteUseCaseProps) => useMutate(\\"DELETE\\", \`/use-cases\`, { ...props }); " `); @@ -1938,13 +1938,13 @@ describe("scripts/import-open-api", () => { expect(generateRestfulComponent(operation, "get", "/fields", [])).toMatchInlineSnapshot(` " - export type ListFieldsProps = Omit, \\"path\\">; + export type ListFieldsProps = Omit, \\"path\\">; /** * List all fields for the use case schema */ export const ListFields = (props: ListFieldsProps) => ( - + path={\`/fields\`} {...props} /> @@ -1955,13 +1955,13 @@ describe("scripts/import-open-api", () => { /** * List all fields for the use case schema */ - export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); + export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); - export type PollListFieldsProps = Omit, \\"path\\">; + export type PollListFieldsProps = Omit, \\"path\\">; // List all fields for the use case schema (long polling) export const PollListFields = (props: PollListFieldsProps) => ( - + path={\`/fields\`} {...props} /> @@ -1993,13 +1993,13 @@ describe("scripts/import-open-api", () => { expect(generateRestfulComponent(operation, "get", "/fields", [])).toMatchInlineSnapshot(` " - export type ListFieldsProps = Omit, \\"path\\">; + export type ListFieldsProps = Omit, \\"path\\">; /** * List all fields for the use case schema */ export const ListFields = (props: ListFieldsProps) => ( - + path={\`/fields\`} {...props} /> @@ -2010,7 +2010,7 @@ describe("scripts/import-open-api", () => { /** * List all fields for the use case schema */ - export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); + export const useListFields = (props: UseListFieldsProps) => useGet(\`/fields\`, { ...props }); " `);