Description
We should use the openAPI spec and generate TypeScript typings from them (the same as we do in Java). That way we'll be able to prevent errors from changes in the API affecting the frontend, as well as errors happening from manually typing new endpoints. Also reviewing PRs that will add new APIs will get easier, since currently this involves a lot of time comparing TypeScript types against the OpenAPI specification to make sure they are correct.
We have two options for generations:
- Generate the whole querying code via the generator, or
- just generate the types of the queries and return values and use them in our own written query code.
Since we currently use react-query, and most common OpenAPI generators are not able to generate query code for that directly, I'd suggest we only generate types for now. Also this will keep us a bit more flexible around our query infrastructure (e.g. around adding Auth to it, etc.), than generating the full query code.
We'll need to figure out which generator to use. The popular OpenAPI generator does unfortunatelly only support generating full query code in TypeScript as far as I can tell. We might need to look for other libraries or check if we can easily just copy types from the query generated code.