7nohe / openapi-react-query-codegen

Node.js library that generates React Query (also called TanStack Query) hooks based on an OpenAPI specification file.
258 stars 25 forks source link

Change OpenAPI generator under the hood #31

Open dani-z opened 11 months ago

dani-z commented 11 months ago

Hi,

First of all I want to thank you for creating this great lib, it saved me a lot of hours of development. I just wanted to ask if you considered swapping the OpenAPI generator under the hood, or if there is any way it can be done in the client implementation. Reason is, my API is using the discriminator mapping feature and currently the typescript generator does not support it (https://github.com/ferdikoomen/openapi-typescript-codegen/issues/998#issuecomment-1090726557)

I was looking at https://github.com/OpenAPITools/openapi-generator-cli and they seem to have it.

Thanks for your help

7nohe commented 11 months ago

@dani-z I think it's likely possible to switch the OpenAPI generator under the hood.

At the moment, there are other OpenAPI generator libraries available, so I recommend considering those as well. They might support discriminator mapping.

It seems that these libraries also support custom hook generation for Tanstack Query. You can see more community projects for Tanstack Query here.

dani-z commented 11 months ago

@7nohe, thanks for the recommendations, I will definitely check them out.

seriouslag commented 5 months ago

@dani-z we have changed the underlying OpenAPI typescript generator to @hey-api/openapi-ts.

I am unsure if the library handles your use case, but they are in active development.

An issue created there, if they do not support it, may be helpful.

dani-z commented 5 months ago

Thanks @seriouslag I had a look at @hey-api in the past, they do indeed seem to be way more active. I guess you could close this issue or make it as a Discussion if you use those. Ideally there will be a configurable way to use what ever generator under the hood, but I am unsure of how complex that could be.

seriouslag commented 5 months ago

Thanks @seriouslag I had a look at @hey-api in the past, they do indeed seem to be way more active. I guess you could close this issue or make it as a Discussion if you use those.

Ideally there will be a configurable way to use what ever generator under the hood, but I am unsure of how complex that could be.

That code will add complexity but that abstraction would be great so we could change generators if needed.

I am not opposed to it being added and if you are up for the task to try, we can collaborate on it.

Personally I feel we should try and enhance @hey-api/openapi-ts as they are responsive and listen to requests.