After running the Swagger Petstore example API through OpenAPI Generator using the command
docker run --rm -it --name openapi-gen -v "$(pwd)":/mnt/workdir -w /mnt/workdir openapitools/openapi-generator-cli generate -i petstore.yaml -g typescript-axios
, I noticed a discrepancy in the resulting types.
When the output is a single statement, the type is Promise<any>
(https://i.sstatic.net/sqqUE.png), but when split into multiple statements, the inferred return type is
Promise<AxiosPromise<User>>
(https://i.sstatic.net/Txaz3.png).
It seems tedious to manually correct each method, especially when it should be working correctly for everyone else. How can I ensure that chained calls generated by openapi-generator
produce the expected types?
Any hints on how to instruct TypeScript that await AxiosPromise<T>
should be treated as T
would be greatly appreciated!