Skip to content

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.

  1. Define handlers in Go — generic functions capture request and response types at compile time
  2. OpenAPI spec generated at runtime — no separate spec file to maintain
  3. TypeScript types generated at build time — Vite or Next.js plugins regenerate types on every save
  4. Fully-typed client — your frontend gets auto-complete and compile-time type checking
  • 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 via errors.As
  • Middleware — apply standard func(http.Handler) http.Handler middleware at the API, group, or route level with WithMiddleware — middleware resolves from API (outermost) → Group → Route (innermost)
  • Composable options — bundle middleware, errors, and other options into reusable Option values with ComposeOptions
  • Typed HTTP headers — parse, validate, and document HTTP headers with header struct tags
  • File uploads — declare uploads with form tags, get correct multipart/form-data types
  • Interactive docs — Scalar API reference at /docs and OpenAPI spec at /openapi.json
  • Just net/http — implements http.Handler, works with any middleware or router