openapi-codegen
openapi-codegen copied to clipboard
React-query documentation
openapi-codegen relies on React Query, but there is no mention of this in the documentation. Initialy, when I was exploring this package, I had to do quite some digging to find out what setup was needed in relation to React Query. For example, this article does a great job at explaining this setup.
For newcomers it might be confusing that there are missing references to @tanstack/react-query when they initialy run the code generation. Even if they install the package, there's still configuration with QueryClient and QueryClientProvider. I propose to add these steps to the setup instructions in the docs.
Hi @ANDREYDEN, actually it does not totally rely on React Query, (for example you can generate just types or just fetchers, or you can create your own custom generators, etc).
But I agree with you, documentation can be improved. So I created a PR for it https://github.com/fabien0102/openapi-codegen/pull/108
Can you check it? Also, if you have any suggestions and wanna contribute, you are all welcome! 👍
@needim, sounds great, thank you for doing that! If I want to contribute, would I create PRs from #108?
I am interested also to see an example how to use a generated mutation function (for POST) - it would be great if you could include this in your documentation, or if you know of any example.
@SeanCondon a quick example for you:
// definition
const createApiKey = useUserCreateApiKeyMutation({
onSuccess: data => {
alert("Api Key created!")
},
});
<Button
onClick={() => createApiKey.mutate({ pathParams: { id: user.id } })}
loading={createApiKey.isLoading}
>
Create API Key
</Button>
Thanks @needim - that's exactly what I was looking for.
@needim, I'm going to spend some time adding docs to #108, I'll create a small PR shortly, let me know what you think
@ANDREYDEN thanks a lot! I'm very busy these days, so I can't contribute too often, but happy to accept PRs!