Code generation from OpenAPI spec or similar

Hey, I’m wondering what is the status of ReScript codegen from OpenAPI spec or other similar typesafe API descriptions.

I’ve seen some comments from at least @DZakh and @zth about it but I wasn’t able to figure out if there are any repos that are relevant. I’d be happy to at least test or something.

I’m trying to create a type safe bridge between a Rust backend and ReScript client and anything that solves the problem is very interesting to me.

1 Like

Yeah, we’ve discussed this several times, but neither me nor @DZakh has gotten around to pursuing it. If someone else (maybe you @TomiS?) would be interested in spearheading this, then I’m sure we could all rally together to make it happen.

Super interested in seeing this as well myself, I think it could unlock a lot of cool things for ReScript.

2 Likes

Seems like you don’t need to start from scratch at least: GitHub - Darkle/openapi-to-rescript-generator: Generate rescript code from an openapi spec document

1 Like

I think what me and @DZakh was talking about last is simply starting with GitHub - DZakh/rescript-openapi: 🕸️ Typesafe OpenAPI for ReScript, and leverage those types to generate ReScript Schema (Sury now) and ReScript REST for all of the contents. This would include emitting actual ReScript type definitions (records for objects, variants for enums/unions etc).

IIRC what we said was that it’s probably straight forward, just lots of work.

There’s also the alternative track of trying to take an existing OpenAPI client generator for TS (or some other suitable language) and adapt it to ReScript instead. Both tracks are interesting IMO.

2 Likes

Thanks for the update. I’ve also been wanting this for several years already, so maybe it would be time to actually contribute to doing something about it. I’ll see what (if anything) I can do. :sweat_smile:

2 Likes

I’m sure that if you get the ball rolling, we’ll all get excited and help out as much as we can. It’d be a massive contribution to the ecosystem if we could get this working well.

1 Like