Introduction
ShiftAPI is a Go framework that generates an OpenAPI 3.1 spec from your handler types at runtime, then uses a Vite or Next.js plugin to turn that spec into a fully-typed TypeScript client.
How it works
Section titled “How it works”- Define handlers in Go — generic functions capture request and response types at compile time
- OpenAPI spec generated at runtime — no separate spec file to maintain
- TypeScript types generated at build time — Vite or Next.js plugins regenerate types on every save
- Fully-typed client — your frontend gets auto-complete and compile-time type checking
Features
Section titled “Features”- Type-safe handlers — Go generics capture request/response types
- Validation included — struct tags like
validate:"required,email"are enforced and reflected in the OpenAPI schema - Type-safe errors — declare custom error types at the API, group, or route level with
WithError[T](status)— schemas appear in the OpenAPI spec and errors are matched at runtime viaerrors.As - Middleware — apply standard
func(http.Handler) http.Handlermiddleware at the API, group, or route level withWithMiddleware— middleware resolves from API (outermost) → Group → Route (innermost) - Composable options — bundle middleware, errors, and other options into reusable
Optionvalues withComposeOptions - Typed HTTP headers — parse, validate, and document HTTP headers with
headerstruct tags - File uploads — declare uploads with
formtags, get correctmultipart/form-datatypes - Interactive docs — Scalar API reference at
/docsand OpenAPI spec at/openapi.json - Just
net/http— implementshttp.Handler, works with any middleware or router