redux-toolkit
redux-toolkit copied to clipboard
Add an option to encode query arguments in openApi codegen
Hi all,
Currently, there is no way to specify that query arguments should be encoded when generating OpenAPI code using rtk query codegen. This can be a problem if you are using an argument with special characters, such as #.
For example, the following query function would result in an OpenAPI endpoint:
doFoo: build.mutation<void, { foo: string, ... }>({
query: (queryArg) => ({
url: `/api/${queryArg.foo}`,
method: "POST",
body: queryArg.requestObject,
}),
}),
To fix this, I would like to request an option to enable query argument encoding in OpenAPI codegen. This would generate the following query function and generate an encoded endpoint: /api/${encodeURIComponent(queryArg.foo)}
or similar
I believe that this would be a valuable addition to rtk query openAPI codegen, as it would make it easier to use query args with special characters.
Thank you for your consideration.
Meantime I'm using injectEndpoints
and overwriting them which is not ideal.