@@ -860,7 +860,7 @@ describe("generateReactQueryComponents", () => {
860860 ` ) ;
861861 } ) ;
862862
863- it ( "should deal with pathParams" , async ( ) => {
863+ it ( "should deal with pathParams (snake case) " , async ( ) => {
864864 const writeFile = jest . fn ( ) ;
865865 const openAPIDocument : OpenAPIObject = {
866866 openapi : "3.0.0" ,
@@ -969,6 +969,115 @@ describe("generateReactQueryComponents", () => {
969969 ` ) ;
970970 } ) ;
971971
972+ it ( "should deal with pathParams (kebab case)" , async ( ) => {
973+ const writeFile = jest . fn ( ) ;
974+ const openAPIDocument : OpenAPIObject = {
975+ openapi : "3.0.0" ,
976+ info : {
977+ title : "petshop" ,
978+ version : "1.0.0" ,
979+ } ,
980+ components : {
981+ requestBodies : {
982+ UpdatePetRequestBody : {
983+ content : {
984+ "application/json" : {
985+ schema : {
986+ type : "object" ,
987+ properties : {
988+ name : {
989+ type : "string" ,
990+ } ,
991+ } ,
992+ } ,
993+ } ,
994+ } ,
995+ } ,
996+ } ,
997+ } ,
998+ paths : {
999+ "/pet/{pet-id}" : {
1000+ parameters : [
1001+ {
1002+ in : "path" ,
1003+ name : "pet-id" ,
1004+ schema : {
1005+ type : "string" ,
1006+ } ,
1007+ required : true ,
1008+ } ,
1009+ ] ,
1010+ put : {
1011+ operationId : "updatePet" ,
1012+ requestBody : {
1013+ $ref : "#/components/requestBodies/UpdatePetRequestBody" ,
1014+ } ,
1015+ responses : {
1016+ 200 : {
1017+ content : {
1018+ "application/json" : {
1019+ description : "Successful response" ,
1020+ schema : {
1021+ type : "string" ,
1022+ } ,
1023+ } ,
1024+ } ,
1025+ } ,
1026+ } ,
1027+ } ,
1028+ } ,
1029+ } ,
1030+ } ;
1031+ await generateReactQueryComponents (
1032+ {
1033+ openAPIDocument,
1034+ writeFile,
1035+ existsFile : ( ) => true ,
1036+ readFile : async ( ) => "" ,
1037+ } ,
1038+ config
1039+ ) ;
1040+
1041+ expect ( writeFile . mock . calls [ 0 ] [ 0 ] ) . toBe ( "petstoreComponents.ts" ) ;
1042+ expect ( writeFile . mock . calls [ 0 ] [ 1 ] ) . toMatchInlineSnapshot ( `
1043+ "/**
1044+ * Generated by @openapi-codegen
1045+ *
1046+ * @version 1.0.0
1047+ */
1048+ import * as reactQuery from \\"@tanstack/react-query\\";
1049+ import { usePetstoreContext, PetstoreContext } from \\"./petstoreContext\\";
1050+ import type * as Fetcher from \\"./petstoreFetcher\\";
1051+ import { petstoreFetch } from \\"./petstoreFetcher\\";
1052+ import type * as RequestBodies from \\"./petstoreRequestBodies\\";
1053+
1054+ export type UpdatePetPathParams = {
1055+ petId: string;
1056+ };
1057+
1058+ export type UpdatePetError = Fetcher.ErrorWrapper<undefined>;
1059+
1060+ export type UpdatePetVariables = {
1061+ body?: RequestBodies.UpdatePetRequestBody;
1062+ pathParams: UpdatePetPathParams;
1063+ } & PetstoreContext[\\"fetcherOptions\\"];
1064+
1065+ export const fetchUpdatePet = (variables: UpdatePetVariables, signal?: AbortSignal) => petstoreFetch<string, UpdatePetError, RequestBodies.UpdatePetRequestBody, {}, {}, UpdatePetPathParams>({ url: \\"/pet/{petId}\\", method: \\"put\\", ...variables, signal });
1066+
1067+ export const useUpdatePet = (options?: Omit<reactQuery.UseMutationOptions<string, UpdatePetError, UpdatePetVariables>, \\"mutationFn\\">) => {
1068+ const { fetcherOptions } = usePetstoreContext();
1069+ return reactQuery.useMutation<string, UpdatePetError, UpdatePetVariables>((variables: UpdatePetVariables) => fetchUpdatePet({ ...fetcherOptions, ...variables }), options);
1070+ };
1071+
1072+ export type QueryOperation = {
1073+ path: string;
1074+ operationId: never;
1075+ variables: unknown;
1076+ };
1077+ "
1078+ ` ) ;
1079+ } ) ;
1080+
9721081 it ( "should build components without prefix" , async ( ) => {
9731082 const writeFile = jest . fn ( ) ;
9741083 const openAPIDocument : OpenAPIObject = {
0 commit comments