diff --git a/packages/@straw-hat/openapi-web-sdk-generator/src/dir.ts b/packages/@straw-hat/openapi-web-sdk-generator/src/dir.ts index 9d6aeb91..cb2d76e2 100644 --- a/packages/@straw-hat/openapi-web-sdk-generator/src/dir.ts +++ b/packages/@straw-hat/openapi-web-sdk-generator/src/dir.ts @@ -1,5 +1,5 @@ import { deleteAsync } from 'del'; -import makeDir from 'make-dir'; +import { makeDirectory } from 'make-dir'; import * as fs from 'node:fs/promises'; import * as path from 'node:path'; import { createDebugger, formatCode } from './helpers.js'; @@ -34,7 +34,7 @@ export class Dir { createDir(...pathsSegments: string[]) { const dirPath = this.resolve(...pathsSegments); this.debug(`Ensure directory ${dirPath}`); - return makeDir(dirPath); + return makeDirectory(dirPath); } readFile(relativePath: string) { diff --git a/packages/@straw-hat/openapi-web-sdk-generator/src/engine/add-typescript-type.ts b/packages/@straw-hat/openapi-web-sdk-generator/src/engine/add-typescript-type.ts index c1fe4a5c..1eb5fe81 100644 --- a/packages/@straw-hat/openapi-web-sdk-generator/src/engine/add-typescript-type.ts +++ b/packages/@straw-hat/openapi-web-sdk-generator/src/engine/add-typescript-type.ts @@ -163,6 +163,16 @@ function integerType(scope: Scope, schema: OpenAPIV3.NonArraySchemaObject) { return numberType(scope, schema); } + +function nullType(scope: Scope, schema: OpenAPIV3.NonArraySchemaObject) { + return scope.maybeRegisterType(schema, { + name: undefined, + definition: 'null', + docs: createDocs(schema), + }); +} + + function unknownType(scope: Scope, schema: OpenAPIV3.NonArraySchemaObject) { return scope.maybeRegisterType(schema, { name: undefined, @@ -267,6 +277,10 @@ export async function addTypeScripType( case 'integer': { return integerType(scope, schema); } + // @ts-expect-error TODO: fix openapi-types to allow null + case 'null': { + return nullType(scope, schema); + } default: { return unknownType(scope, schema); } diff --git a/packages/@straw-hat/openapi-web-sdk-generator/tests/vitest/__snapshots__/fetcher.test.ts.snap b/packages/@straw-hat/openapi-web-sdk-generator/tests/vitest/__snapshots__/fetcher.test.ts.snap index ab8c6a58..6c4bb749 100644 --- a/packages/@straw-hat/openapi-web-sdk-generator/tests/vitest/__snapshots__/fetcher.test.ts.snap +++ b/packages/@straw-hat/openapi-web-sdk-generator/tests/vitest/__snapshots__/fetcher.test.ts.snap @@ -1,22 +1,22 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`fetcher generator > add-pet.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getRequestBody, getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; -import * as schemas from \\"./components/schemas\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getRequestBody, getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; +import * as schemas from "./components/schemas"; export type AddPetBodyParams = schemas.Pet; export type AddPetParams = Pick< OperationParams, - \\"options\\" | \\"body\\" + "options" | "body" >; export type AddPetResponse = schemas.Pet; -export function addPetUrlPath(params: Omit) { - return createUrlPath(\\"/pet\\", params); +export function addPetUrlPath(params: Omit) { + return createUrlPath("/pet", params); } export async function addPet( @@ -26,7 +26,7 @@ export async function addPet( const url = addPetUrlPath(params); const response = await client(url, { - method: \\"POST\\", + method: "POST", body: getRequestBody(params.body), signal: params.options?.signal, }); @@ -37,7 +37,7 @@ export async function addPet( `; exports[`fetcher generator > components/schemas.ts 1`] = ` -"import * as schemas from \\"./schemas\\"; +"import * as schemas from "./schemas"; export type Order = { /** @@ -59,7 +59,7 @@ export type Order = { /** * Order Status */ - status?: \\"placed\\" | \\"approved\\" | \\"delivered\\"; + status?: "placed" | "approved" | "delivered"; complete?: boolean; }; @@ -143,7 +143,7 @@ export type Pet = { /** * pet status in the store */ - status?: \\"available\\" | \\"pending\\" | \\"sold\\"; + status?: "available" | "pending" | "sold"; }; export type ApiResponse = { @@ -157,17 +157,17 @@ export type ApiResponse = { message?: string; }; -export const ORDER_STATUS_PLACED = \\"placed\\"; -export const ORDER_STATUS_APPROVED = \\"approved\\"; -export const ORDER_STATUS_DELIVERED = \\"delivered\\"; +export const ORDER_STATUS_PLACED = "placed"; +export const ORDER_STATUS_APPROVED = "approved"; +export const ORDER_STATUS_DELIVERED = "delivered"; export const ORDER_STATUS = [ ORDER_STATUS_PLACED, ORDER_STATUS_APPROVED, ORDER_STATUS_DELIVERED, ]; -export const PET_STATUS_AVAILABLE = \\"available\\"; -export const PET_STATUS_PENDING = \\"pending\\"; -export const PET_STATUS_2 = \\"sold\\"; +export const PET_STATUS_AVAILABLE = "available"; +export const PET_STATUS_PENDING = "pending"; +export const PET_STATUS_2 = "sold"; export const PET_STATUS = [ PET_STATUS_AVAILABLE, PET_STATUS_PENDING, @@ -183,7 +183,7 @@ function isZero(value: number) { } export function getOrderId(order: Order) { - return order[\\"id\\"]; + return order["id"]; } export function isEqualToOrderId(order: Order, target: number) { @@ -191,7 +191,7 @@ export function isEqualToOrderId(order: Order, target: number) { } export function getOrderPetId(order: Order) { - return order[\\"petId\\"]; + return order["petId"]; } export function isEqualToOrderPetId(order: Order, target: number) { @@ -199,7 +199,7 @@ export function isEqualToOrderPetId(order: Order, target: number) { } export function getOrderQuantity(order: Order) { - return order[\\"quantity\\"]; + return order["quantity"]; } export function isEqualToOrderQuantity(order: Order, target: number) { @@ -207,7 +207,7 @@ export function isEqualToOrderQuantity(order: Order, target: number) { } export function getOrderShipDate(order: Order) { - return order[\\"shipDate\\"]; + return order["shipDate"]; } export function isEqualToOrderShipDate(order: Order, target: string) { @@ -231,7 +231,7 @@ export function isOrderShipDateEmpty(order: Order) { } export function getOrderStatus(order: Order) { - return order[\\"status\\"]; + return order["status"]; } export function isEqualToOrderStatus(order: Order, target: string) { @@ -247,13 +247,13 @@ export function getOrderStatusUpperCased(order: Order) { } export function isOrderStatusPlaced( - value: \\"placed\\" | \\"approved\\" | \\"delivered\\", + value: "placed" | "approved" | "delivered", ) { return value === ORDER_STATUS_PLACED; } export function isNotOrderStatusPlaced( - value: \\"placed\\" | \\"approved\\" | \\"delivered\\", + value: "placed" | "approved" | "delivered", ) { return value !== ORDER_STATUS_PLACED; } @@ -267,13 +267,13 @@ export function isNotOrderWithStatusPlaced(order: Order) { } export function isOrderStatusApproved( - value: \\"placed\\" | \\"approved\\" | \\"delivered\\", + value: "placed" | "approved" | "delivered", ) { return value === ORDER_STATUS_APPROVED; } export function isNotOrderStatusApproved( - value: \\"placed\\" | \\"approved\\" | \\"delivered\\", + value: "placed" | "approved" | "delivered", ) { return value !== ORDER_STATUS_APPROVED; } @@ -287,13 +287,13 @@ export function isNotOrderWithStatusApproved(order: Order) { } export function isOrderStatusDelivered( - value: \\"placed\\" | \\"approved\\" | \\"delivered\\", + value: "placed" | "approved" | "delivered", ) { return value === ORDER_STATUS_DELIVERED; } export function isNotOrderStatusDelivered( - value: \\"placed\\" | \\"approved\\" | \\"delivered\\", + value: "placed" | "approved" | "delivered", ) { return value !== ORDER_STATUS_DELIVERED; } @@ -311,7 +311,7 @@ export function isOrderStatus(value: string) { } export function getOrderComplete(order: Order) { - return order[\\"complete\\"]; + return order["complete"]; } export function isOrderComplete(order: Order) { @@ -327,7 +327,7 @@ export function isEqualToOrderComplete(order: Order, target: boolean) { } export function getCustomerId(customer: Customer) { - return customer[\\"id\\"]; + return customer["id"]; } export function isEqualToCustomerId(customer: Customer, target: number) { @@ -335,7 +335,7 @@ export function isEqualToCustomerId(customer: Customer, target: number) { } export function getCustomerUsername(customer: Customer) { - return customer[\\"username\\"]; + return customer["username"]; } export function isEqualToCustomerUsername(customer: Customer, target: string) { @@ -359,11 +359,11 @@ export function isCustomerUsernameEmpty(customer: Customer) { } export function getCustomerAddress(customer: Customer) { - return customer[\\"address\\"]; + return customer["address"]; } export function getAddressStreet(address: Address) { - return address[\\"street\\"]; + return address["street"]; } export function isEqualToAddressStreet(address: Address, target: string) { @@ -387,7 +387,7 @@ export function isAddressStreetEmpty(address: Address) { } export function getAddressCity(address: Address) { - return address[\\"city\\"]; + return address["city"]; } export function isEqualToAddressCity(address: Address, target: string) { @@ -411,7 +411,7 @@ export function isAddressCityEmpty(address: Address) { } export function getAddressState(address: Address) { - return address[\\"state\\"]; + return address["state"]; } export function isEqualToAddressState(address: Address, target: string) { @@ -435,7 +435,7 @@ export function isAddressStateEmpty(address: Address) { } export function getAddressZip(address: Address) { - return address[\\"zip\\"]; + return address["zip"]; } export function isEqualToAddressZip(address: Address, target: string) { @@ -459,7 +459,7 @@ export function isAddressZipEmpty(address: Address) { } export function getCategoryId(category: Category) { - return category[\\"id\\"]; + return category["id"]; } export function isEqualToCategoryId(category: Category, target: number) { @@ -467,7 +467,7 @@ export function isEqualToCategoryId(category: Category, target: number) { } export function getCategoryName(category: Category) { - return category[\\"name\\"]; + return category["name"]; } export function isEqualToCategoryName(category: Category, target: string) { @@ -491,7 +491,7 @@ export function isCategoryNameEmpty(category: Category) { } export function getUserId(user: User) { - return user[\\"id\\"]; + return user["id"]; } export function isEqualToUserId(user: User, target: number) { @@ -499,7 +499,7 @@ export function isEqualToUserId(user: User, target: number) { } export function getUserUsername(user: User) { - return user[\\"username\\"]; + return user["username"]; } export function isEqualToUserUsername(user: User, target: string) { @@ -523,7 +523,7 @@ export function isUserUsernameEmpty(user: User) { } export function getUserFirstName(user: User) { - return user[\\"firstName\\"]; + return user["firstName"]; } export function isEqualToUserFirstName(user: User, target: string) { @@ -547,7 +547,7 @@ export function isUserFirstNameEmpty(user: User) { } export function getUserLastName(user: User) { - return user[\\"lastName\\"]; + return user["lastName"]; } export function isEqualToUserLastName(user: User, target: string) { @@ -571,7 +571,7 @@ export function isUserLastNameEmpty(user: User) { } export function getUserEmail(user: User) { - return user[\\"email\\"]; + return user["email"]; } export function isEqualToUserEmail(user: User, target: string) { @@ -595,7 +595,7 @@ export function isUserEmailEmpty(user: User) { } export function getUserPassword(user: User) { - return user[\\"password\\"]; + return user["password"]; } export function isEqualToUserPassword(user: User, target: string) { @@ -619,7 +619,7 @@ export function isUserPasswordEmpty(user: User) { } export function getUserPhone(user: User) { - return user[\\"phone\\"]; + return user["phone"]; } export function isEqualToUserPhone(user: User, target: string) { @@ -643,7 +643,7 @@ export function isUserPhoneEmpty(user: User) { } export function getUserUserStatus(user: User) { - return user[\\"userStatus\\"]; + return user["userStatus"]; } export function isEqualToUserUserStatus(user: User, target: number) { @@ -651,7 +651,7 @@ export function isEqualToUserUserStatus(user: User, target: number) { } export function getTagId(tag: Tag) { - return tag[\\"id\\"]; + return tag["id"]; } export function isEqualToTagId(tag: Tag, target: number) { @@ -659,7 +659,7 @@ export function isEqualToTagId(tag: Tag, target: number) { } export function getTagName(tag: Tag) { - return tag[\\"name\\"]; + return tag["name"]; } export function isEqualToTagName(tag: Tag, target: string) { @@ -683,7 +683,7 @@ export function isTagNameEmpty(tag: Tag) { } export function getPetId(pet: Pet) { - return pet[\\"id\\"]; + return pet["id"]; } export function isEqualToPetId(pet: Pet, target: number) { @@ -691,7 +691,7 @@ export function isEqualToPetId(pet: Pet, target: number) { } export function getPetName(pet: Pet) { - return pet[\\"name\\"]; + return pet["name"]; } export function isEqualToPetName(pet: Pet, target: string) { @@ -711,15 +711,15 @@ export function isPetNameEmpty(pet: Pet) { } export function getPetPhotoUrls(pet: Pet) { - return pet[\\"photoUrls\\"]; + return pet["photoUrls"]; } export function getPetTags(pet: Pet) { - return pet[\\"tags\\"]; + return pet["tags"]; } export function getPetStatus(pet: Pet) { - return pet[\\"status\\"]; + return pet["status"]; } export function isEqualToPetStatus(pet: Pet, target: string) { @@ -734,12 +734,12 @@ export function getPetStatusUpperCased(pet: Pet) { return getPetStatus(pet)?.toUpperCase(); } -export function isPetStatusAvailable(value: \\"available\\" | \\"pending\\" | \\"sold\\") { +export function isPetStatusAvailable(value: "available" | "pending" | "sold") { return value === PET_STATUS_AVAILABLE; } export function isNotPetStatusAvailable( - value: \\"available\\" | \\"pending\\" | \\"sold\\", + value: "available" | "pending" | "sold", ) { return value !== PET_STATUS_AVAILABLE; } @@ -752,11 +752,11 @@ export function isNotPetWithStatusAvailable(pet: Pet) { return getPetStatus(pet) !== PET_STATUS_AVAILABLE; } -export function isPetStatusPending(value: \\"available\\" | \\"pending\\" | \\"sold\\") { +export function isPetStatusPending(value: "available" | "pending" | "sold") { return value === PET_STATUS_PENDING; } -export function isNotPetStatusPending(value: \\"available\\" | \\"pending\\" | \\"sold\\") { +export function isNotPetStatusPending(value: "available" | "pending" | "sold") { return value !== PET_STATUS_PENDING; } @@ -768,11 +768,11 @@ export function isNotPetWithStatusPending(pet: Pet) { return getPetStatus(pet) !== PET_STATUS_PENDING; } -export function isPetStatus2(value: \\"available\\" | \\"pending\\" | \\"sold\\") { +export function isPetStatus2(value: "available" | "pending" | "sold") { return value === PET_STATUS_2; } -export function isNotPetStatus2(value: \\"available\\" | \\"pending\\" | \\"sold\\") { +export function isNotPetStatus2(value: "available" | "pending" | "sold") { return value !== PET_STATUS_2; } @@ -789,7 +789,7 @@ export function isPetStatus(value: string) { } export function getApiResponseCode(apiResponse: ApiResponse) { - return apiResponse[\\"code\\"]; + return apiResponse["code"]; } export function isEqualToApiResponseCode( @@ -800,7 +800,7 @@ export function isEqualToApiResponseCode( } export function getApiResponseType(apiResponse: ApiResponse) { - return apiResponse[\\"type\\"]; + return apiResponse["type"]; } export function isEqualToApiResponseType( @@ -827,7 +827,7 @@ export function isApiResponseTypeEmpty(apiResponse: ApiResponse) { } export function getApiResponseMessage(apiResponse: ApiResponse) { - return apiResponse[\\"message\\"]; + return apiResponse["message"]; } export function isEqualToApiResponseMessage( @@ -856,22 +856,22 @@ export function isApiResponseMessageEmpty(apiResponse: ApiResponse) { `; exports[`fetcher generator > create-user.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getRequestBody, getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; -import * as schemas from \\"./components/schemas\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getRequestBody, getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; +import * as schemas from "./components/schemas"; export type CreateUserBodyParams = schemas.User; export type CreateUserParams = Pick< OperationParams, - \\"options\\" | \\"body\\" + "options" | "body" >; export type CreateUserResponse = unknown; -export function createUserUrlPath(params: Omit) { - return createUrlPath(\\"/user\\", params); +export function createUserUrlPath(params: Omit) { + return createUrlPath("/user", params); } export async function createUser( @@ -881,7 +881,7 @@ export async function createUser( const url = createUserUrlPath(params); const response = await client(url, { - method: \\"POST\\", + method: "POST", body: getRequestBody(params.body), signal: params.options?.signal, }); @@ -892,24 +892,24 @@ export async function createUser( `; exports[`fetcher generator > create-users-with-list-input.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getRequestBody, getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; -import * as schemas from \\"./components/schemas\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getRequestBody, getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; +import * as schemas from "./components/schemas"; export type CreateUsersWithListInputBodyParams = Array; export type CreateUsersWithListInputParams = Pick< OperationParams, - \\"options\\" | \\"body\\" + "options" | "body" >; export type CreateUsersWithListInputResponse = schemas.User; export function createUsersWithListInputUrlPath( - params: Omit, + params: Omit, ) { - return createUrlPath(\\"/user/createWithList\\", params); + return createUrlPath("/user/createWithList", params); } export async function createUsersWithListInput( @@ -919,7 +919,7 @@ export async function createUsersWithListInput( const url = createUsersWithListInputUrlPath(params); const response = await client(url, { - method: \\"POST\\", + method: "POST", body: getRequestBody(params.body), signal: params.options?.signal, }); @@ -930,9 +930,9 @@ export async function createUsersWithListInput( `; exports[`fetcher generator > delete-order.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; export type DeleteOrderPathParams = { /** @@ -944,14 +944,14 @@ export type DeleteOrderPathParams = { export type DeleteOrderParams = Pick< OperationParams, - \\"options\\" | \\"path\\" + "options" | "path" >; export type DeleteOrderResponse = unknown; -export function deleteOrderUrlPath(params: Omit) { +export function deleteOrderUrlPath(params: Omit) { return createUrlPath( - \\"/store/order/{orderId}\\", + "/store/order/{orderId}", params, ); } @@ -963,7 +963,7 @@ export async function deleteOrder( const url = deleteOrderUrlPath(params); const response = await client(url, { - method: \\"DELETE\\", + method: "DELETE", signal: params.options?.signal, }); @@ -974,9 +974,9 @@ export async function deleteOrder( `; exports[`fetcher generator > delete-pet.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; export type DeletePetPathParams = { /** @@ -988,13 +988,13 @@ export type DeletePetPathParams = { export type DeletePetParams = Pick< OperationParams, - \\"options\\" | \\"path\\" + "options" | "path" >; export type DeletePetResponse = unknown; -export function deletePetUrlPath(params: Omit) { - return createUrlPath(\\"/pet/{petId}\\", params); +export function deletePetUrlPath(params: Omit) { + return createUrlPath("/pet/{petId}", params); } export async function deletePet( @@ -1004,7 +1004,7 @@ export async function deletePet( const url = deletePetUrlPath(params); const response = await client(url, { - method: \\"DELETE\\", + method: "DELETE", signal: params.options?.signal, }); @@ -1015,9 +1015,9 @@ export async function deletePet( `; exports[`fetcher generator > delete-user.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; export type DeleteUserPathParams = { /** @@ -1028,13 +1028,13 @@ export type DeleteUserPathParams = { export type DeleteUserParams = Pick< OperationParams, - \\"options\\" | \\"path\\" + "options" | "path" >; export type DeleteUserResponse = unknown; -export function deleteUserUrlPath(params: Omit) { - return createUrlPath(\\"/user/{username}\\", params); +export function deleteUserUrlPath(params: Omit) { + return createUrlPath("/user/{username}", params); } export async function deleteUser( @@ -1044,7 +1044,7 @@ export async function deleteUser( const url = deleteUserUrlPath(params); const response = await client(url, { - method: \\"DELETE\\", + method: "DELETE", signal: params.options?.signal, }); @@ -1055,31 +1055,31 @@ export async function deleteUser( `; exports[`fetcher generator > find-pets-by-status.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; -import * as schemas from \\"./components/schemas\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; +import * as schemas from "./components/schemas"; export type FindPetsByStatusQueryParams = { /** * Status values that need to be considered for filter * @default available */ - status?: \\"available\\" | \\"pending\\" | \\"sold\\"; + status?: "available" | "pending" | "sold"; }; export type FindPetsByStatusParams = Pick< OperationParams, - \\"options\\" | \\"query\\" + "options" | "query" >; export type FindPetsByStatusResponse = Array; export function findPetsByStatusUrlPath( - params: Omit, + params: Omit, ) { return createUrlPath( - \\"/pet/findByStatus\\", + "/pet/findByStatus", params, ); } @@ -1091,7 +1091,7 @@ export async function findPetsByStatus( const url = findPetsByStatusUrlPath(params); const response = await client(url, { - method: \\"GET\\", + method: "GET", signal: params.options?.signal, }); @@ -1102,10 +1102,50 @@ export async function findPetsByStatus( `; exports[`fetcher generator > find-pets-by-tags.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; -import * as schemas from \\"./components/schemas\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; +import * as schemas from "./components/schemas"; + +import * as schemas from "./components/schemas"; + +export type FindPetsByTagsQueryParams = { + /** + * Tags to filter by + */ + tags?: Array; +}; + +export type FindPetsByTagsParams = Pick< + OperationParams, + "options" | "query" +>; + +export type FindPetsByTagsResponse = Array; + +export function findPetsByTagsUrlPath( + params: Omit, +) { + return createUrlPath( + "/pet/findByTags", + params, + ); +} + +export async function findPetsByTags( + client: Fetcher, + params: FindPetsByTagsParams, +): Promise { + const url = findPetsByTagsUrlPath(params); + + const response = await client(url, { + method: "GET", + + signal: params.options?.signal, + }); + + return getResponseBody(response); +} export type FindPetsByTagsQueryParams = { /** @@ -1116,16 +1156,16 @@ export type FindPetsByTagsQueryParams = { export type FindPetsByTagsParams = Pick< OperationParams, - \\"options\\" | \\"query\\" + "options" | "query" >; export type FindPetsByTagsResponse = Array; export function findPetsByTagsUrlPath( - params: Omit, + params: Omit, ) { return createUrlPath( - \\"/pet/findByTags\\", + "/pet/findByTags", params, ); } @@ -1137,7 +1177,7 @@ export async function findPetsByTags( const url = findPetsByTagsUrlPath(params); const response = await client(url, { - method: \\"GET\\", + method: "GET", signal: params.options?.signal, }); @@ -1148,21 +1188,21 @@ export async function findPetsByTags( `; exports[`fetcher generator > get-inventory.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; export type GetInventoryParams = Pick< OperationParams, - \\"options\\" + "options" >; export type GetInventoryResponse = {}; export function getInventoryUrlPath( - params: Omit, + params: Omit, ) { - return createUrlPath(\\"/store/inventory\\", params); + return createUrlPath("/store/inventory", params); } export async function getInventory( @@ -1172,7 +1212,7 @@ export async function getInventory( const url = getInventoryUrlPath(params); const response = await client(url, { - method: \\"GET\\", + method: "GET", signal: params.options?.signal, }); @@ -1183,10 +1223,10 @@ export async function getInventory( `; exports[`fetcher generator > get-order-by-id.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; -import * as schemas from \\"./components/schemas\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; +import * as schemas from "./components/schemas"; export type GetOrderByIdPathParams = { /** @@ -1198,16 +1238,16 @@ export type GetOrderByIdPathParams = { export type GetOrderByIdParams = Pick< OperationParams, - \\"options\\" | \\"path\\" + "options" | "path" >; export type GetOrderByIdResponse = schemas.Order; export function getOrderByIdUrlPath( - params: Omit, + params: Omit, ) { return createUrlPath( - \\"/store/order/{orderId}\\", + "/store/order/{orderId}", params, ); } @@ -1219,7 +1259,7 @@ export async function getOrderById( const url = getOrderByIdUrlPath(params); const response = await client(url, { - method: \\"GET\\", + method: "GET", signal: params.options?.signal, }); @@ -1230,10 +1270,10 @@ export async function getOrderById( `; exports[`fetcher generator > get-pet-by-id.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; -import * as schemas from \\"./components/schemas\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; +import * as schemas from "./components/schemas"; export type GetPetByIdPathParams = { /** @@ -1245,13 +1285,13 @@ export type GetPetByIdPathParams = { export type GetPetByIdParams = Pick< OperationParams, - \\"options\\" | \\"path\\" + "options" | "path" >; export type GetPetByIdResponse = schemas.Pet; -export function getPetByIdUrlPath(params: Omit) { - return createUrlPath(\\"/pet/{petId}\\", params); +export function getPetByIdUrlPath(params: Omit) { + return createUrlPath("/pet/{petId}", params); } export async function getPetById( @@ -1261,7 +1301,7 @@ export async function getPetById( const url = getPetByIdUrlPath(params); const response = await client(url, { - method: \\"GET\\", + method: "GET", signal: params.options?.signal, }); @@ -1272,10 +1312,10 @@ export async function getPetById( `; exports[`fetcher generator > get-user-by-name.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; -import * as schemas from \\"./components/schemas\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; +import * as schemas from "./components/schemas"; export type GetUserByNamePathParams = { /** @@ -1286,16 +1326,16 @@ export type GetUserByNamePathParams = { export type GetUserByNameParams = Pick< OperationParams, - \\"options\\" | \\"path\\" + "options" | "path" >; export type GetUserByNameResponse = schemas.User; export function getUserByNameUrlPath( - params: Omit, + params: Omit, ) { return createUrlPath( - \\"/user/{username}\\", + "/user/{username}", params, ); } @@ -1307,7 +1347,7 @@ export async function getUserByName( const url = getUserByNameUrlPath(params); const response = await client(url, { - method: \\"GET\\", + method: "GET", signal: params.options?.signal, }); @@ -1318,32 +1358,51 @@ export async function getUserByName( `; exports[`fetcher generator > index.ts 1`] = ` -"export * from \\"./update-pet\\"; -export * from \\"./add-pet\\"; -export * from \\"./find-pets-by-status\\"; -export * from \\"./find-pets-by-tags\\"; -export * from \\"./get-pet-by-id\\"; -export * from \\"./update-pet-with-form\\"; -export * from \\"./delete-pet\\"; -export * from \\"./upload-file\\"; -export * from \\"./get-inventory\\"; -export * from \\"./place-order\\"; -export * from \\"./get-order-by-id\\"; -export * from \\"./delete-order\\"; -export * from \\"./create-user\\"; -export * from \\"./create-users-with-list-input\\"; -export * from \\"./login-user\\"; -export * from \\"./logout-user\\"; -export * from \\"./get-user-by-name\\"; -export * from \\"./update-user\\"; -export * from \\"./delete-user\\"; +"export * from "./update-pet"; +export * from "./update-pet"; +export * from "./add-pet"; +export * from "./add-pet"; +export * from "./find-pets-by-status"; +export * from "./find-pets-by-status"; +export * from "./find-pets-by-tags"; +export * from "./get-pet-by-id"; +export * from "./update-pet-with-form"; +export * from "./find-pets-by-tags"; +export * from "./delete-pet"; +export * from "./get-pet-by-id"; +export * from "./update-pet-with-form"; +export * from "./delete-pet"; +export * from "./upload-file"; +export * from "./upload-file"; +export * from "./get-inventory"; +export * from "./get-inventory"; +export * from "./place-order"; +export * from "./get-order-by-id"; +export * from "./place-order"; +export * from "./delete-order"; +export * from "./get-order-by-id"; +export * from "./create-user"; +export * from "./create-users-with-list-input"; +export * from "./delete-order"; +export * from "./login-user"; +export * from "./create-user"; +export * from "./create-users-with-list-input"; +export * from "./logout-user"; +export * from "./login-user"; +export * from "./logout-user"; +export * from "./get-user-by-name"; +export * from "./get-user-by-name"; +export * from "./update-user"; +export * from "./update-user"; +export * from "./delete-user"; +export * from "./delete-user"; " `; exports[`fetcher generator > login-user.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; export type LoginUserQueryParams = { /** @@ -1358,13 +1417,13 @@ export type LoginUserQueryParams = { export type LoginUserParams = Pick< OperationParams, - \\"options\\" | \\"query\\" + "options" | "query" >; export type LoginUserResponse = string; -export function loginUserUrlPath(params: Omit) { - return createUrlPath(\\"/user/login\\", params); +export function loginUserUrlPath(params: Omit) { + return createUrlPath("/user/login", params); } export async function loginUser( @@ -1374,7 +1433,7 @@ export async function loginUser( const url = loginUserUrlPath(params); const response = await client(url, { - method: \\"GET\\", + method: "GET", signal: params.options?.signal, }); @@ -1385,19 +1444,19 @@ export async function loginUser( `; exports[`fetcher generator > logout-user.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; export type LogoutUserParams = Pick< OperationParams, - \\"options\\" + "options" >; export type LogoutUserResponse = unknown; -export function logoutUserUrlPath(params: Omit) { - return createUrlPath(\\"/user/logout\\", params); +export function logoutUserUrlPath(params: Omit) { + return createUrlPath("/user/logout", params); } export async function logoutUser( @@ -1407,7 +1466,7 @@ export async function logoutUser( const url = logoutUserUrlPath(params); const response = await client(url, { - method: \\"GET\\", + method: "GET", signal: params.options?.signal, }); @@ -1418,22 +1477,22 @@ export async function logoutUser( `; exports[`fetcher generator > place-order.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getRequestBody, getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; -import * as schemas from \\"./components/schemas\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getRequestBody, getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; +import * as schemas from "./components/schemas"; export type PlaceOrderBodyParams = schemas.Order; export type PlaceOrderParams = Pick< OperationParams, - \\"options\\" | \\"body\\" + "options" | "body" >; export type PlaceOrderResponse = schemas.Order; -export function placeOrderUrlPath(params: Omit) { - return createUrlPath(\\"/store/order\\", params); +export function placeOrderUrlPath(params: Omit) { + return createUrlPath("/store/order", params); } export async function placeOrder( @@ -1443,7 +1502,7 @@ export async function placeOrder( const url = placeOrderUrlPath(params); const response = await client(url, { - method: \\"POST\\", + method: "POST", body: getRequestBody(params.body), signal: params.options?.signal, }); @@ -1454,22 +1513,22 @@ export async function placeOrder( `; exports[`fetcher generator > update-pet.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getRequestBody, getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; -import * as schemas from \\"./components/schemas\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getRequestBody, getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; +import * as schemas from "./components/schemas"; export type UpdatePetBodyParams = schemas.Pet; export type UpdatePetParams = Pick< OperationParams, - \\"options\\" | \\"body\\" + "options" | "body" >; export type UpdatePetResponse = schemas.Pet; -export function updatePetUrlPath(params: Omit) { - return createUrlPath(\\"/pet\\", params); +export function updatePetUrlPath(params: Omit) { + return createUrlPath("/pet", params); } export async function updatePet( @@ -1479,7 +1538,7 @@ export async function updatePet( const url = updatePetUrlPath(params); const response = await client(url, { - method: \\"PUT\\", + method: "PUT", body: getRequestBody(params.body), signal: params.options?.signal, }); @@ -1490,9 +1549,9 @@ export async function updatePet( `; exports[`fetcher generator > update-pet-with-form.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; export type UpdatePetWithFormPathParams = { /** @@ -1519,18 +1578,18 @@ export type UpdatePetWithFormParams = Pick< UpdatePetWithFormQueryParams, never >, - \\"options\\" | \\"path\\" | \\"query\\" + "options" | "path" | "query" >; export type UpdatePetWithFormResponse = unknown; export function updatePetWithFormUrlPath( - params: Omit, + params: Omit, ) { return createUrlPath< UpdatePetWithFormPathParams, UpdatePetWithFormQueryParams - >(\\"/pet/{petId}\\", params); + >("/pet/{petId}", params); } export async function updatePetWithForm( @@ -1540,7 +1599,7 @@ export async function updatePetWithForm( const url = updatePetWithFormUrlPath(params); const response = await client(url, { - method: \\"POST\\", + method: "POST", signal: params.options?.signal, }); @@ -1551,10 +1610,10 @@ export async function updatePetWithForm( `; exports[`fetcher generator > update-user.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getRequestBody, getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; -import * as schemas from \\"./components/schemas\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getRequestBody, getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; +import * as schemas from "./components/schemas"; export type UpdateUserPathParams = { /** @@ -1567,13 +1626,13 @@ export type UpdateUserBodyParams = schemas.User; export type UpdateUserParams = Pick< OperationParams, - \\"options\\" | \\"body\\" | \\"path\\" + "options" | "body" | "path" >; export type UpdateUserResponse = unknown; -export function updateUserUrlPath(params: Omit) { - return createUrlPath(\\"/user/{username}\\", params); +export function updateUserUrlPath(params: Omit) { + return createUrlPath("/user/{username}", params); } export async function updateUser( @@ -1583,7 +1642,7 @@ export async function updateUser( const url = updateUserUrlPath(params); const response = await client(url, { - method: \\"PUT\\", + method: "PUT", body: getRequestBody(params.body), signal: params.options?.signal, }); @@ -1594,10 +1653,10 @@ export async function updateUser( `; exports[`fetcher generator > upload-file.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import { getRequestBody, getResponseBody } from \\"@straw-hat/fetcher\\"; -import { createUrlPath, OperationParams } from \\"@straw-hat/fetcher/openapi\\"; -import * as schemas from \\"./components/schemas\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import { getRequestBody, getResponseBody } from "@straw-hat/fetcher"; +import { createUrlPath, OperationParams } from "@straw-hat/fetcher/openapi"; +import * as schemas from "./components/schemas"; export type UploadFilePathParams = { /** @@ -1622,14 +1681,14 @@ export type UploadFileParams = Pick< UploadFileQueryParams, UploadFileBodyParams >, - \\"options\\" | \\"body\\" | \\"path\\" | \\"query\\" + "options" | "body" | "path" | "query" >; export type UploadFileResponse = schemas.ApiResponse; -export function uploadFileUrlPath(params: Omit) { +export function uploadFileUrlPath(params: Omit) { return createUrlPath( - \\"/pet/{petId}/uploadImage\\", + "/pet/{petId}/uploadImage", params, ); } @@ -1641,7 +1700,7 @@ export async function uploadFile( const url = uploadFileUrlPath(params); const response = await client(url, { - method: \\"POST\\", + method: "POST", body: getRequestBody(params.body), signal: params.options?.signal, }); diff --git a/packages/@straw-hat/openapi-web-sdk-generator/tests/vitest/__snapshots__/react-query-fetcher.test.ts.snap b/packages/@straw-hat/openapi-web-sdk-generator/tests/vitest/__snapshots__/react-query-fetcher.test.ts.snap index d5fce008..a0489881 100644 --- a/packages/@straw-hat/openapi-web-sdk-generator/tests/vitest/__snapshots__/react-query-fetcher.test.ts.snap +++ b/packages/@straw-hat/openapi-web-sdk-generator/tests/vitest/__snapshots__/react-query-fetcher.test.ts.snap @@ -1,45 +1,64 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`react-query-fetcher generator > index.ts 1`] = ` -"export * from \\"./use-update-pet\\"; -export * from \\"./use-add-pet\\"; -export * from \\"./use-find-pets-by-status\\"; -export * from \\"./use-find-pets-by-tags\\"; -export * from \\"./use-get-pet-by-id\\"; -export * from \\"./use-update-pet-with-form\\"; -export * from \\"./use-delete-pet\\"; -export * from \\"./use-upload-file\\"; -export * from \\"./use-get-inventory\\"; -export * from \\"./use-place-order\\"; -export * from \\"./use-get-order-by-id\\"; -export * from \\"./use-delete-order\\"; -export * from \\"./use-create-user\\"; -export * from \\"./use-create-users-with-list-input\\"; -export * from \\"./use-login-user\\"; -export * from \\"./use-logout-user\\"; -export * from \\"./use-get-user-by-name\\"; -export * from \\"./use-update-user\\"; -export * from \\"./use-delete-user\\"; +"export * from "./use-update-pet"; +export * from "./use-add-pet"; +export * from "./use-update-pet"; +export * from "./use-find-pets-by-status"; +export * from "./use-find-pets-by-tags"; +export * from "./use-add-pet"; +export * from "./use-get-pet-by-id"; +export * from "./use-update-pet-with-form"; +export * from "./use-delete-pet"; +export * from "./use-find-pets-by-status"; +export * from "./use-find-pets-by-tags"; +export * from "./use-upload-file"; +export * from "./use-get-pet-by-id"; +export * from "./use-update-pet-with-form"; +export * from "./use-get-inventory"; +export * from "./use-delete-pet"; +export * from "./use-place-order"; +export * from "./use-upload-file"; +export * from "./use-get-inventory"; +export * from "./use-get-order-by-id"; +export * from "./use-place-order"; +export * from "./use-delete-order"; +export * from "./use-get-order-by-id"; +export * from "./use-delete-order"; +export * from "./use-create-user"; +export * from "./use-create-users-with-list-input"; +export * from "./use-login-user"; +export * from "./use-logout-user"; +export * from "./use-get-user-by-name"; +export * from "./use-create-user"; +export * from "./use-update-user"; +export * from "./use-delete-user"; +export * from "./use-create-users-with-list-input"; +export * from "./use-login-user"; +export * from "./use-logout-user"; +export * from "./use-get-user-by-name"; +export * from "./use-update-user"; +export * from "./use-delete-user"; " `; exports[`react-query-fetcher generator > use-add-pet.ts 1`] = ` -"import type { UseMutationOptions } from \\"@tanstack/react-query\\"; -import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { AddPetResponse, AddPetParams } from \\"@my-sdk/pepeg\\"; -import { useFetcherMutation } from \\"@straw-hat/react-query-fetcher\\"; -import { addPet } from \\"@my-sdk/pepeg\\"; +"import type { UseMutationOptions } from "@tanstack/react-query"; +import type { Fetcher } from "@straw-hat/fetcher"; +import type { AddPetResponse, AddPetParams } from "@my-sdk/pepeg"; +import { useFetcherMutation } from "@straw-hat/react-query-fetcher"; +import { addPet } from "@my-sdk/pepeg"; -export type UseAddPetVariables = Omit; +export type UseAddPetVariables = Omit; export type UseAddPetArgs = { options?: Omit< UseMutationOptions, - \\"mutationKey\\" + "mutationKey" >; }; -const MUTATION_KEY = [\\"addPet\\"] as const; +const MUTATION_KEY = ["addPet"] as const; export function useAddPet( client: Fetcher, @@ -61,22 +80,22 @@ export function useAddPet( `; exports[`react-query-fetcher generator > use-create-user.ts 1`] = ` -"import type { UseMutationOptions } from \\"@tanstack/react-query\\"; -import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { CreateUserResponse, CreateUserParams } from \\"@my-sdk/pepeg\\"; -import { useFetcherMutation } from \\"@straw-hat/react-query-fetcher\\"; -import { createUser } from \\"@my-sdk/pepeg\\"; +"import type { UseMutationOptions } from "@tanstack/react-query"; +import type { Fetcher } from "@straw-hat/fetcher"; +import type { CreateUserResponse, CreateUserParams } from "@my-sdk/pepeg"; +import { useFetcherMutation } from "@straw-hat/react-query-fetcher"; +import { createUser } from "@my-sdk/pepeg"; -export type UseCreateUserVariables = Omit; +export type UseCreateUserVariables = Omit; export type UseCreateUserArgs = { options?: Omit< UseMutationOptions, - \\"mutationKey\\" + "mutationKey" >; }; -const MUTATION_KEY = [\\"createUser\\"] as const; +const MUTATION_KEY = ["createUser"] as const; export function useCreateUser( client: Fetcher, @@ -98,18 +117,18 @@ export function useCreateUser( `; exports[`react-query-fetcher generator > use-create-users-with-list-input.ts 1`] = ` -"import type { UseMutationOptions } from \\"@tanstack/react-query\\"; -import type { Fetcher } from \\"@straw-hat/fetcher\\"; +"import type { UseMutationOptions } from "@tanstack/react-query"; +import type { Fetcher } from "@straw-hat/fetcher"; import type { CreateUsersWithListInputResponse, CreateUsersWithListInputParams, -} from \\"@my-sdk/pepeg\\"; -import { useFetcherMutation } from \\"@straw-hat/react-query-fetcher\\"; -import { createUsersWithListInput } from \\"@my-sdk/pepeg\\"; +} from "@my-sdk/pepeg"; +import { useFetcherMutation } from "@straw-hat/react-query-fetcher"; +import { createUsersWithListInput } from "@my-sdk/pepeg"; export type UseCreateUsersWithListInputVariables = Omit< CreateUsersWithListInputParams, - \\"options\\" + "options" >; export type UseCreateUsersWithListInputArgs = { @@ -119,11 +138,11 @@ export type UseCreateUsersWithListInputArgs = { TError, UseCreateUsersWithListInputVariables >, - \\"mutationKey\\" + "mutationKey" >; }; -const MUTATION_KEY = [\\"createUsersWithListInput\\"] as const; +const MUTATION_KEY = ["createUsersWithListInput"] as const; export function useCreateUsersWithListInput( client: Fetcher, @@ -146,22 +165,22 @@ export function useCreateUsersWithListInput( `; exports[`react-query-fetcher generator > use-delete-order.ts 1`] = ` -"import type { UseMutationOptions } from \\"@tanstack/react-query\\"; -import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { DeleteOrderResponse, DeleteOrderParams } from \\"@my-sdk/pepeg\\"; -import { useFetcherMutation } from \\"@straw-hat/react-query-fetcher\\"; -import { deleteOrder } from \\"@my-sdk/pepeg\\"; +"import type { UseMutationOptions } from "@tanstack/react-query"; +import type { Fetcher } from "@straw-hat/fetcher"; +import type { DeleteOrderResponse, DeleteOrderParams } from "@my-sdk/pepeg"; +import { useFetcherMutation } from "@straw-hat/react-query-fetcher"; +import { deleteOrder } from "@my-sdk/pepeg"; -export type UseDeleteOrderVariables = Omit; +export type UseDeleteOrderVariables = Omit; export type UseDeleteOrderArgs = { options?: Omit< UseMutationOptions, - \\"mutationKey\\" + "mutationKey" >; }; -const MUTATION_KEY = [\\"deleteOrder\\"] as const; +const MUTATION_KEY = ["deleteOrder"] as const; export function useDeleteOrder( client: Fetcher, @@ -184,22 +203,22 @@ export function useDeleteOrder( `; exports[`react-query-fetcher generator > use-delete-pet.ts 1`] = ` -"import type { UseMutationOptions } from \\"@tanstack/react-query\\"; -import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { DeletePetResponse, DeletePetParams } from \\"@my-sdk/pepeg\\"; -import { useFetcherMutation } from \\"@straw-hat/react-query-fetcher\\"; -import { deletePet } from \\"@my-sdk/pepeg\\"; +"import type { UseMutationOptions } from "@tanstack/react-query"; +import type { Fetcher } from "@straw-hat/fetcher"; +import type { DeletePetResponse, DeletePetParams } from "@my-sdk/pepeg"; +import { useFetcherMutation } from "@straw-hat/react-query-fetcher"; +import { deletePet } from "@my-sdk/pepeg"; -export type UseDeletePetVariables = Omit; +export type UseDeletePetVariables = Omit; export type UseDeletePetArgs = { options?: Omit< UseMutationOptions, - \\"mutationKey\\" + "mutationKey" >; }; -const MUTATION_KEY = [\\"deletePet\\"] as const; +const MUTATION_KEY = ["deletePet"] as const; export function useDeletePet( client: Fetcher, @@ -221,22 +240,22 @@ export function useDeletePet( `; exports[`react-query-fetcher generator > use-delete-user.ts 1`] = ` -"import type { UseMutationOptions } from \\"@tanstack/react-query\\"; -import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { DeleteUserResponse, DeleteUserParams } from \\"@my-sdk/pepeg\\"; -import { useFetcherMutation } from \\"@straw-hat/react-query-fetcher\\"; -import { deleteUser } from \\"@my-sdk/pepeg\\"; +"import type { UseMutationOptions } from "@tanstack/react-query"; +import type { Fetcher } from "@straw-hat/fetcher"; +import type { DeleteUserResponse, DeleteUserParams } from "@my-sdk/pepeg"; +import { useFetcherMutation } from "@straw-hat/react-query-fetcher"; +import { deleteUser } from "@my-sdk/pepeg"; -export type UseDeleteUserVariables = Omit; +export type UseDeleteUserVariables = Omit; export type UseDeleteUserArgs = { options?: Omit< UseMutationOptions, - \\"mutationKey\\" + "mutationKey" >; }; -const MUTATION_KEY = [\\"deleteUser\\"] as const; +const MUTATION_KEY = ["deleteUser"] as const; export function useDeleteUser( client: Fetcher, @@ -258,19 +277,19 @@ export function useDeleteUser( `; exports[`react-query-fetcher generator > use-find-pets-by-status.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { UseFetcherQueryArgs } from \\"@straw-hat/react-query-fetcher\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import type { UseFetcherQueryArgs } from "@straw-hat/react-query-fetcher"; import type { FindPetsByStatusResponse, FindPetsByStatusParams, -} from \\"@my-sdk/pepeg\\"; +} from "@my-sdk/pepeg"; import { createQueryKey, useFetcherQuery, -} from \\"@straw-hat/react-query-fetcher\\"; -import { findPetsByStatus } from \\"@my-sdk/pepeg\\"; +} from "@straw-hat/react-query-fetcher"; +import { findPetsByStatus } from "@my-sdk/pepeg"; -export type UseFindPetsByStatusParams = Omit; +export type UseFindPetsByStatusParams = Omit; export type UseFindPetsByStatusArgs = Omit< UseFetcherQueryArgs< @@ -279,10 +298,10 @@ export type UseFindPetsByStatusArgs = Omit< TData, UseFindPetsByStatusParams >, - \\"queryKey\\" | \\"endpoint\\" + "queryKey" | "endpoint" >; -const QUERY_KEY = [\\"findPetsByStatus\\"] as const; +const QUERY_KEY = ["findPetsByStatus"] as const; export function useFindPetsByStatusQueryKey( params?: UseFindPetsByStatusParams, @@ -309,19 +328,19 @@ export function useFindPetsByStatus< `; exports[`react-query-fetcher generator > use-find-pets-by-tags.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { UseFetcherQueryArgs } from \\"@straw-hat/react-query-fetcher\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import type { UseFetcherQueryArgs } from "@straw-hat/react-query-fetcher"; import type { FindPetsByTagsResponse, FindPetsByTagsParams, -} from \\"@my-sdk/pepeg\\"; +} from "@my-sdk/pepeg"; import { createQueryKey, useFetcherQuery, -} from \\"@straw-hat/react-query-fetcher\\"; -import { findPetsByTags } from \\"@my-sdk/pepeg\\"; +} from "@straw-hat/react-query-fetcher"; +import { findPetsByTags } from "@my-sdk/pepeg"; -export type UseFindPetsByTagsParams = Omit; +export type UseFindPetsByTagsParams = Omit; export type UseFindPetsByTagsArgs = Omit< UseFetcherQueryArgs< @@ -330,10 +349,10 @@ export type UseFindPetsByTagsArgs = Omit< TData, UseFindPetsByTagsParams >, - \\"queryKey\\" | \\"endpoint\\" + "queryKey" | "endpoint" >; -const QUERY_KEY = [\\"findPetsByTags\\"] as const; +const QUERY_KEY = ["findPetsByTags"] as const; export function useFindPetsByTagsQueryKey(params?: UseFindPetsByTagsParams) { return createQueryKey(QUERY_KEY, params); @@ -358,16 +377,16 @@ export function useFindPetsByTags< `; exports[`react-query-fetcher generator > use-get-inventory.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { UseFetcherQueryArgs } from \\"@straw-hat/react-query-fetcher\\"; -import type { GetInventoryResponse, GetInventoryParams } from \\"@my-sdk/pepeg\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import type { UseFetcherQueryArgs } from "@straw-hat/react-query-fetcher"; +import type { GetInventoryResponse, GetInventoryParams } from "@my-sdk/pepeg"; import { createQueryKey, useFetcherQuery, -} from \\"@straw-hat/react-query-fetcher\\"; -import { getInventory } from \\"@my-sdk/pepeg\\"; +} from "@straw-hat/react-query-fetcher"; +import { getInventory } from "@my-sdk/pepeg"; -export type UseGetInventoryParams = Omit; +export type UseGetInventoryParams = Omit; export type UseGetInventoryArgs = Omit< UseFetcherQueryArgs< @@ -376,10 +395,10 @@ export type UseGetInventoryArgs = Omit< TData, UseGetInventoryParams >, - \\"queryKey\\" | \\"endpoint\\" + "queryKey" | "endpoint" >; -const QUERY_KEY = [\\"getInventory\\"] as const; +const QUERY_KEY = ["getInventory"] as const; export function useGetInventoryQueryKey(params?: UseGetInventoryParams) { return createQueryKey(QUERY_KEY, params); @@ -404,16 +423,16 @@ export function useGetInventory( `; exports[`react-query-fetcher generator > use-get-order-by-id.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { UseFetcherQueryArgs } from \\"@straw-hat/react-query-fetcher\\"; -import type { GetOrderByIdResponse, GetOrderByIdParams } from \\"@my-sdk/pepeg\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import type { UseFetcherQueryArgs } from "@straw-hat/react-query-fetcher"; +import type { GetOrderByIdResponse, GetOrderByIdParams } from "@my-sdk/pepeg"; import { createQueryKey, useFetcherQuery, -} from \\"@straw-hat/react-query-fetcher\\"; -import { getOrderById } from \\"@my-sdk/pepeg\\"; +} from "@straw-hat/react-query-fetcher"; +import { getOrderById } from "@my-sdk/pepeg"; -export type UseGetOrderByIdParams = Omit; +export type UseGetOrderByIdParams = Omit; export type UseGetOrderByIdArgs = Omit< UseFetcherQueryArgs< @@ -422,10 +441,10 @@ export type UseGetOrderByIdArgs = Omit< TData, UseGetOrderByIdParams >, - \\"queryKey\\" | \\"endpoint\\" + "queryKey" | "endpoint" >; -const QUERY_KEY = [\\"getOrderById\\"] as const; +const QUERY_KEY = ["getOrderById"] as const; export function useGetOrderByIdQueryKey(params?: UseGetOrderByIdParams) { return createQueryKey(QUERY_KEY, params); @@ -450,23 +469,23 @@ export function useGetOrderById( `; exports[`react-query-fetcher generator > use-get-pet-by-id.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { UseFetcherQueryArgs } from \\"@straw-hat/react-query-fetcher\\"; -import type { GetPetByIdResponse, GetPetByIdParams } from \\"@my-sdk/pepeg\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import type { UseFetcherQueryArgs } from "@straw-hat/react-query-fetcher"; +import type { GetPetByIdResponse, GetPetByIdParams } from "@my-sdk/pepeg"; import { createQueryKey, useFetcherQuery, -} from \\"@straw-hat/react-query-fetcher\\"; -import { getPetById } from \\"@my-sdk/pepeg\\"; +} from "@straw-hat/react-query-fetcher"; +import { getPetById } from "@my-sdk/pepeg"; -export type UseGetPetByIdParams = Omit; +export type UseGetPetByIdParams = Omit; export type UseGetPetByIdArgs = Omit< UseFetcherQueryArgs, - \\"queryKey\\" | \\"endpoint\\" + "queryKey" | "endpoint" >; -const QUERY_KEY = [\\"getPetById\\"] as const; +const QUERY_KEY = ["getPetById"] as const; export function useGetPetByIdQueryKey(params?: UseGetPetByIdParams) { return createQueryKey(QUERY_KEY, params); @@ -491,16 +510,16 @@ export function useGetPetById( `; exports[`react-query-fetcher generator > use-get-user-by-name.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { UseFetcherQueryArgs } from \\"@straw-hat/react-query-fetcher\\"; -import type { GetUserByNameResponse, GetUserByNameParams } from \\"@my-sdk/pepeg\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import type { UseFetcherQueryArgs } from "@straw-hat/react-query-fetcher"; +import type { GetUserByNameResponse, GetUserByNameParams } from "@my-sdk/pepeg"; import { createQueryKey, useFetcherQuery, -} from \\"@straw-hat/react-query-fetcher\\"; -import { getUserByName } from \\"@my-sdk/pepeg\\"; +} from "@straw-hat/react-query-fetcher"; +import { getUserByName } from "@my-sdk/pepeg"; -export type UseGetUserByNameParams = Omit; +export type UseGetUserByNameParams = Omit; export type UseGetUserByNameArgs = Omit< UseFetcherQueryArgs< @@ -509,10 +528,10 @@ export type UseGetUserByNameArgs = Omit< TData, UseGetUserByNameParams >, - \\"queryKey\\" | \\"endpoint\\" + "queryKey" | "endpoint" >; -const QUERY_KEY = [\\"getUserByName\\"] as const; +const QUERY_KEY = ["getUserByName"] as const; export function useGetUserByNameQueryKey(params?: UseGetUserByNameParams) { return createQueryKey(QUERY_KEY, params); @@ -537,23 +556,23 @@ export function useGetUserByName< `; exports[`react-query-fetcher generator > use-login-user.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { UseFetcherQueryArgs } from \\"@straw-hat/react-query-fetcher\\"; -import type { LoginUserResponse, LoginUserParams } from \\"@my-sdk/pepeg\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import type { UseFetcherQueryArgs } from "@straw-hat/react-query-fetcher"; +import type { LoginUserResponse, LoginUserParams } from "@my-sdk/pepeg"; import { createQueryKey, useFetcherQuery, -} from \\"@straw-hat/react-query-fetcher\\"; -import { loginUser } from \\"@my-sdk/pepeg\\"; +} from "@straw-hat/react-query-fetcher"; +import { loginUser } from "@my-sdk/pepeg"; -export type UseLoginUserParams = Omit; +export type UseLoginUserParams = Omit; export type UseLoginUserArgs = Omit< UseFetcherQueryArgs, - \\"queryKey\\" | \\"endpoint\\" + "queryKey" | "endpoint" >; -const QUERY_KEY = [\\"loginUser\\"] as const; +const QUERY_KEY = ["loginUser"] as const; export function useLoginUserQueryKey(params?: UseLoginUserParams) { return createQueryKey(QUERY_KEY, params); @@ -576,23 +595,23 @@ export function useLoginUser( `; exports[`react-query-fetcher generator > use-logout-user.ts 1`] = ` -"import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { UseFetcherQueryArgs } from \\"@straw-hat/react-query-fetcher\\"; -import type { LogoutUserResponse, LogoutUserParams } from \\"@my-sdk/pepeg\\"; +"import type { Fetcher } from "@straw-hat/fetcher"; +import type { UseFetcherQueryArgs } from "@straw-hat/react-query-fetcher"; +import type { LogoutUserResponse, LogoutUserParams } from "@my-sdk/pepeg"; import { createQueryKey, useFetcherQuery, -} from \\"@straw-hat/react-query-fetcher\\"; -import { logoutUser } from \\"@my-sdk/pepeg\\"; +} from "@straw-hat/react-query-fetcher"; +import { logoutUser } from "@my-sdk/pepeg"; -export type UseLogoutUserParams = Omit; +export type UseLogoutUserParams = Omit; export type UseLogoutUserArgs = Omit< UseFetcherQueryArgs, - \\"queryKey\\" | \\"endpoint\\" + "queryKey" | "endpoint" >; -const QUERY_KEY = [\\"logoutUser\\"] as const; +const QUERY_KEY = ["logoutUser"] as const; export function useLogoutUserQueryKey(params?: UseLogoutUserParams) { return createQueryKey(QUERY_KEY, params); @@ -617,22 +636,22 @@ export function useLogoutUser( `; exports[`react-query-fetcher generator > use-place-order.ts 1`] = ` -"import type { UseMutationOptions } from \\"@tanstack/react-query\\"; -import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { PlaceOrderResponse, PlaceOrderParams } from \\"@my-sdk/pepeg\\"; -import { useFetcherMutation } from \\"@straw-hat/react-query-fetcher\\"; -import { placeOrder } from \\"@my-sdk/pepeg\\"; +"import type { UseMutationOptions } from "@tanstack/react-query"; +import type { Fetcher } from "@straw-hat/fetcher"; +import type { PlaceOrderResponse, PlaceOrderParams } from "@my-sdk/pepeg"; +import { useFetcherMutation } from "@straw-hat/react-query-fetcher"; +import { placeOrder } from "@my-sdk/pepeg"; -export type UsePlaceOrderVariables = Omit; +export type UsePlaceOrderVariables = Omit; export type UsePlaceOrderArgs = { options?: Omit< UseMutationOptions, - \\"mutationKey\\" + "mutationKey" >; }; -const MUTATION_KEY = [\\"placeOrder\\"] as const; +const MUTATION_KEY = ["placeOrder"] as const; export function usePlaceOrder( client: Fetcher, @@ -654,22 +673,22 @@ export function usePlaceOrder( `; exports[`react-query-fetcher generator > use-update-pet.ts 1`] = ` -"import type { UseMutationOptions } from \\"@tanstack/react-query\\"; -import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { UpdatePetResponse, UpdatePetParams } from \\"@my-sdk/pepeg\\"; -import { useFetcherMutation } from \\"@straw-hat/react-query-fetcher\\"; -import { updatePet } from \\"@my-sdk/pepeg\\"; +"import type { UseMutationOptions } from "@tanstack/react-query"; +import type { Fetcher } from "@straw-hat/fetcher"; +import type { UpdatePetResponse, UpdatePetParams } from "@my-sdk/pepeg"; +import { useFetcherMutation } from "@straw-hat/react-query-fetcher"; +import { updatePet } from "@my-sdk/pepeg"; -export type UseUpdatePetVariables = Omit; +export type UseUpdatePetVariables = Omit; export type UseUpdatePetArgs = { options?: Omit< UseMutationOptions, - \\"mutationKey\\" + "mutationKey" >; }; -const MUTATION_KEY = [\\"updatePet\\"] as const; +const MUTATION_KEY = ["updatePet"] as const; export function useUpdatePet( client: Fetcher, @@ -691,18 +710,18 @@ export function useUpdatePet( `; exports[`react-query-fetcher generator > use-update-pet-with-form.ts 1`] = ` -"import type { UseMutationOptions } from \\"@tanstack/react-query\\"; -import type { Fetcher } from \\"@straw-hat/fetcher\\"; +"import type { UseMutationOptions } from "@tanstack/react-query"; +import type { Fetcher } from "@straw-hat/fetcher"; import type { UpdatePetWithFormResponse, UpdatePetWithFormParams, -} from \\"@my-sdk/pepeg\\"; -import { useFetcherMutation } from \\"@straw-hat/react-query-fetcher\\"; -import { updatePetWithForm } from \\"@my-sdk/pepeg\\"; +} from "@my-sdk/pepeg"; +import { useFetcherMutation } from "@straw-hat/react-query-fetcher"; +import { updatePetWithForm } from "@my-sdk/pepeg"; export type UseUpdatePetWithFormVariables = Omit< UpdatePetWithFormParams, - \\"options\\" + "options" >; export type UseUpdatePetWithFormArgs = { @@ -712,11 +731,11 @@ export type UseUpdatePetWithFormArgs = { TError, UseUpdatePetWithFormVariables >, - \\"mutationKey\\" + "mutationKey" >; }; -const MUTATION_KEY = [\\"updatePetWithForm\\"] as const; +const MUTATION_KEY = ["updatePetWithForm"] as const; export function useUpdatePetWithForm( client: Fetcher, @@ -739,22 +758,22 @@ export function useUpdatePetWithForm( `; exports[`react-query-fetcher generator > use-update-user.ts 1`] = ` -"import type { UseMutationOptions } from \\"@tanstack/react-query\\"; -import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { UpdateUserResponse, UpdateUserParams } from \\"@my-sdk/pepeg\\"; -import { useFetcherMutation } from \\"@straw-hat/react-query-fetcher\\"; -import { updateUser } from \\"@my-sdk/pepeg\\"; +"import type { UseMutationOptions } from "@tanstack/react-query"; +import type { Fetcher } from "@straw-hat/fetcher"; +import type { UpdateUserResponse, UpdateUserParams } from "@my-sdk/pepeg"; +import { useFetcherMutation } from "@straw-hat/react-query-fetcher"; +import { updateUser } from "@my-sdk/pepeg"; -export type UseUpdateUserVariables = Omit; +export type UseUpdateUserVariables = Omit; export type UseUpdateUserArgs = { options?: Omit< UseMutationOptions, - \\"mutationKey\\" + "mutationKey" >; }; -const MUTATION_KEY = [\\"updateUser\\"] as const; +const MUTATION_KEY = ["updateUser"] as const; export function useUpdateUser( client: Fetcher, @@ -776,22 +795,22 @@ export function useUpdateUser( `; exports[`react-query-fetcher generator > use-upload-file.ts 1`] = ` -"import type { UseMutationOptions } from \\"@tanstack/react-query\\"; -import type { Fetcher } from \\"@straw-hat/fetcher\\"; -import type { UploadFileResponse, UploadFileParams } from \\"@my-sdk/pepeg\\"; -import { useFetcherMutation } from \\"@straw-hat/react-query-fetcher\\"; -import { uploadFile } from \\"@my-sdk/pepeg\\"; +"import type { UseMutationOptions } from "@tanstack/react-query"; +import type { Fetcher } from "@straw-hat/fetcher"; +import type { UploadFileResponse, UploadFileParams } from "@my-sdk/pepeg"; +import { useFetcherMutation } from "@straw-hat/react-query-fetcher"; +import { uploadFile } from "@my-sdk/pepeg"; -export type UseUploadFileVariables = Omit; +export type UseUploadFileVariables = Omit; export type UseUploadFileArgs = { options?: Omit< UseMutationOptions, - \\"mutationKey\\" + "mutationKey" >; }; -const MUTATION_KEY = [\\"uploadFile\\"] as const; +const MUTATION_KEY = ["uploadFile"] as const; export function useUploadFile( client: Fetcher, diff --git a/packages/experimentals/@straw-hat/cli-core/src/helpers.ts b/packages/experimentals/@straw-hat/cli-core/src/helpers.ts index 8168a2c7..82af9def 100644 --- a/packages/experimentals/@straw-hat/cli-core/src/helpers.ts +++ b/packages/experimentals/@straw-hat/cli-core/src/helpers.ts @@ -2,7 +2,7 @@ import { FancyMap } from '@straw-hat/fancy-map'; import { config as dotenvConfig } from 'dotenv'; import { expand as dotenvExpand } from 'dotenv-expand'; import * as fs from 'fs'; -import makeDir from 'make-dir'; +import { makeDirectory } from 'make-dir'; import * as path from 'path'; import resolve from 'resolve'; import { createDebugger } from './debug'; @@ -72,7 +72,7 @@ export function touchFileSync(filePath: string) { throw err; } - makeDir.sync(path.dirname(filePath)); + makeDirectory.sync(path.dirname(filePath)); } fs.writeFileSync(filePath, '');