discord-gophers / goapi-gen

This package contains a set of utilities for generating Go boilerplate code for services based on OpenAPI 3.0 API definitions
Apache License 2.0
137 stars 12 forks source link

feat: client generation #103

Open Karitham opened 1 year ago

Karitham commented 1 year ago

Not tested enough, but I'm throwing the idea out there.

This is WIP, and uses an external package for building requests.

We could technically copy over the external code, or generate it alongside the client, but I thought relying on a battle tested library was worth it, even though it makes for an extra dependency.

The generated code is decent. The only thing I'm unhappy about is how API errors don't get coalesced into an error, because we would have to figure out what errors are (500s+ only?).

We could also pattern match on ($error^ i). It's still decent to work with though.