3

I have a nestjs project in which I am using nestjs-swagger for generating open API spec. I am using that to auto-generate client code for typescript-axios. The issue is that the client code is not generating generics properly. In the attached github code, I want the return type of findAll API to be AxiosPromise<PaginatedResponseOfCreateCatDto> but it is generating AxiosPromise<PaginatedDto & object>> as return type.

This same thing is explained in nestjs docs here: https://docs.nestjs.com/openapi/operations#advanced-generic-apiresponse. I have reproduced exact same steps in https://github.com/garvit14/nest/tree/issue-with-generics-when-generating-client/sample/11-swagger but it is not working.

I am using https://github.com/OpenAPITools/openapi-generator for generating typescript-axios client. Command: openapi-generator-cli generate -g typescript-axios -i specFile.json -o .. In the linked github repo I have added the code for generated client also: https://github.com/garvit14/nest/tree/issue-with-generics-when-generating-client/sample/11-swagger/src/genererated-client. I have tried this on node 10.24.1 and 12.22.6. Is there any way I can solve this issue?

Thanks in advance

optimus
  • 76
  • 3

0 Answers0