tunarr icon indicating copy to clipboard operation
tunarr copied to clipboard

Re-explore auto-client generation for API

Open chrisbenincasa opened this issue 1 year ago • 2 comments

We had this working initially using Swagger / OpenAPI -> Zodios client generation, but there were a few problems:

  1. Updating a shared type, generating the client, etc was sorta a pain. Not seamless.
  2. More importantly, there was an issue with the impl we were using to generate the Zod types where discriminated unions wren't treated properly. Discriminated unions are used heavily in Tunarr, so we had to remove the client generation and define our Zodios client manually.

It's possible that https://github.com/colinhacks/zod/discussions/2109 will help things, if this ever lands. That said, we'd also have to ensure that whatever OpenAPI => Zod translator we used is updated.

Another idea is to rethink the entire pipeline. The old implementation was really roundabout, considering both the server and client are typed with Zod (i.e. the intermediate OpenAPI step seems unnecessary...). Maybe there is a Fastify => Zodios generator out there.

chrisbenincasa avatar Mar 15 '24 20:03 chrisbenincasa

Are you referring to an internal in-app client, or an external client library/SDK for interacting with Tunarr?

As the dev on dizqueTV's Python client library and the subsequent automation scripts, I'd be happy to offer assistance.

nwithan8 avatar Mar 31 '24 03:03 nwithan8

Hey @nwithan8 sorry for the delay! So my original motivation for opening this issue was for the internal client.

We're definitely eager to take any help we can get, so if you feel inclined to jump in, please do! I wish I had documented the issues I was I was experiencing a bit more before opening this issue.

One was definitely the dev experience of having to regen the client manually and dealing with the rough edges of a pnpm monorepo to have the editor pick up the type changes, etc. this might be solved now that we use turborepo though.

chrisbenincasa avatar Apr 05 '24 22:04 chrisbenincasa