OpenAPITools / OpenAPITools/openapi-generator
[REQ] [typescript-axios] Make ParamCreator not async
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
I use generated client ( typescript-axios ) methods inside my js but sometimes I just need to construct my API url. In theory this can be done by ParamCreator but ones returns Promise. So now it's not easy to use ParamCreator for components that require url argument as a simple string.
For example:
- UploadFile (antd) component takes string url for file upload.
- React-PDF takes string url for display pdf by itself (without using api client).
There is an example of Promise in ParamCreator
https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/petstore/typescript-axios/builds/with-single-request-parameters/api.ts#L260
Describe the solution you'd like
ParamCreator makes not heavy job so the solution is just to remove async and Promise from declaration.
addPet: async (body: Pet, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
->
addPet: (body: Pet, options: AxiosRequestConfig = {}): RequestArgs => {
I think this changes shouldn't make any problems but add new advantages
Describe alternatives you've considered
As workaround now I have to construct url by string concatenation (it is easy but not scalable) or patch generated api client (cut async and Promise from ParamCreator declaration signature).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the referenced samples/client/petstore/typescript-axios/builds/with-single-request-parameters/api.ts entry point and inspect how ParamCreator is generated. Confirm the requested change makes ParamCreator return RequestArgs directly rather than a Promise, and verify the generated TypeScript client still supports constructing URL arguments synchronously.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100