Generate a Go SDK from your OpenAPI spec
Octri reads your OpenAPI document and writes a Go client on the standard library, pushes it to your repository with a semver tag, and rebuilds it every time the spec changes.
go get github.com/acme/acme-goThe client they actually get
What your users write once the Go package is installed.
Two call-site shapes come out of the same spec. class-namespaced is the default: a client object whose operations are grouped by resource, which is the surface every widely used SDK ships and the one your own reference docs already assume. functions is the override, and it is the one to reach for when your users care about tree-shaking. It is a single setting, per language, and nothing else about the client changes with it.
Context first and errors last either way, on net/http, with no third-party dependency in your users’ builds.
Go modules resolve from a repository rather than a registry, so there is no account to connect. Octri pushes the generated code and a semver tag, and go get resolves it from there.
import acme "github.com/acme/acme-go"
client := acme.NewAcme(acme.ClientConfig{
BaseURL: "https://api.acme.com/v1",
Auth: &acme.ClientAuthConfig{BearerAuth: os.Getenv("ACME_TOKEN")},
})
// The Paginated companion takes a yield callback. Return false to stop early.
err := client.Users.ListPaginated(ctx, nil, &limit, func(user *acme.User) bool {
fmt.Println(user.ID)
return true
})import acme "github.com/acme/acme-go"
acme.Configure(&acme.ClientConfig{
BaseURL: "https://api.acme.com/v1",
Auth: &acme.ClientAuthConfig{BearerAuth: os.Getenv("ACME_TOKEN")},
})
err := acme.ListUsersPaginated(ctx, nil, &limit, func(user *acme.User) bool {
fmt.Println(user.ID)
return true
})What you decide for Go
Go exposes no HTTP engine setting: the generated client uses net/http, which is what a Go consumer expects.
Client style
class-namespaced (default), class, namespaced, functionsA client struct with a field per resource is the default. Package-level functions are the override.
Argument style
positional (default), objectPlain parameters, with a wide operation promoted to a params struct automatically, so you only pay for the struct where it earns its place.
Method naming
short (default), fullShort strips the namespace word, so GetBalance under Balance becomes Balance.Get().
Namespace
tags (default), pathTags decide whether a caller writes client.Invoices.List() or client.V1.List().
Doc comments
full (default), minimalFull carries your spec’s prose into the comments godoc renders.
Decide this before the first release
The repository is the import path
Go derives the module path from the repository URL and writes it into go.mod, so github.com/acme/acme-go is the line every consumer types. Rename or move that repository and every import breaks, with no deprecation path and no redirect. Set the Go repository deliberately before the first tag, and expect it to differ from the repository your other languages use.
In every generated client, not just this one
The parts nobody wants to hand-write, and the parts a hand-written client usually skips.
- Retries with exponential backoff and jitter, on the statuses that mean "try again", with a per-attempt timeout.
- Idempotency keys on the methods that need them, so a retried write does not become two.
- Auth wired in from your spec’s security scheme, read from wherever your users keep secrets.
- Typed errors split by cause: a failed constraint, an HTTP status, a network failure and a timeout are four different things.
- Pagination that follows whichever contract your spec declares, cursor, offset, page number or next URL, without prefetching the collection.
- Server-sent events as a native stream, for the operations that stream.
- Error reporting to Octri’s monitoring, pre-wired and switched off until a consumer opts in.
Point it at your spec
Upload an OpenAPI or Swagger document, paste a URL, or connect the repository it lives in so a merge to main updates it.
Read the audit
The spec is scored out of 10 on what a generator can do with it, with every missing schema and colliding operationId named. 9 of the fourteen rules carry a button that writes the fix.
Shape the client
Client style, argument style, namespacing, auth, retries and pagination, set once for the project and overridden per language or per endpoint.
Generate and read it
The package is generated, compiled and handed to you as source you can read before anyone installs it.
Publish, then keep publishing
Release to the registry under your own account. Every later spec change regenerates the client, and the version comes from your document rather than from us.
Or in another language
One spec, ten languages. These three are generated from the same document, with the same settings, at the same time.
Questions
None. Go modules resolve from a repository and a tag, so Octri pushes the generated code and the semver tag, and go get takes it from there. That is why Go needs the GitHub App connected and does not need a registry token.