redux-toolkit icon indicating copy to clipboard operation
redux-toolkit copied to clipboard

@rtk-query/codegen-openapi code: Ignore /api prefix for naming

Open andordavoti opened this issue 2 years ago • 2 comments

Our API endpoints are prefixed with /api.

Would be nice to be able to ignore this prefix in the config.

Current result: getApiUser: build.query<GetApiUserApiResponse, GetApiUserApiArg>({ query: () => ({ url: '/api/user' }) })

Desired result: getUser: build.query<GetUserApiResponse, GetUserApiArg>({ query: () => ({ url: '/api/user' }) })

andordavoti avatar Nov 30 '23 12:11 andordavoti

is there any workaround for this? for me it is the v1 getV1Development: build.query<GetV1DevelopmentApiResponse, GetV1DevelopmentApiArg>({ query: (queryArg) => ({ url: '/v1/development', params: { name: queryArg.name, companyName: queryArg.companyName } }), }),

IMYannick avatar May 10 '24 12:05 IMYannick

is there any workaround for this? for me it is the v1

`getV1Development: build.query<GetV1DevelopmentApiResponse, GetV1DevelopmentApiArg>({

  query: (queryArg) => ({ url: '/v1/development', params: { name: queryArg.name, companyName: queryArg.companyName } }),

}),`

My current workaround is a shellscript that used the sed command to remove the prefix from the JSON. Which isn't clean, but it works for now. You also have to then in the same shellscript fetch the swagger json file before you remove the prefix and reference the file not the url in your RTK config.

andordavoti avatar May 10 '24 15:05 andordavoti

Being able to pass an endpointNameOverride function in the config would be amazing.

greeze avatar Nov 07 '24 17:11 greeze