Skip to main content
Open Source·OpenAPI 3.x·Go

OPENAPI FOR GO

Framework-agnostic
API docs.

Build OpenAPI 3.x specs in pure Go. No annotations, no code comments. Test-driven, always in sync with what your API actually does.

main.go
package main

import (
  "github.com/oaswrap/spec"
  "github.com/oaswrap/spec/option"
)

func main() {
  r := spec.NewRouter(
    option.WithTitle("My API"),
    option.WithVersion("1.0.0"),
  )

  r.Get("/users/{id}",
    option.Summary("Get user"),
    option.Response(200, new(User)),
  )

  // Write spec to file
  r.WriteSchemaTo("openapi.yaml")
}

Everything you need to ship accurate API docs.

01

Code-first spec generation

Build OpenAPI 3.x and 3.2 specs in pure Go with full type safety. chi, gin, echo, fiber, iris, net/http, gorilla/mux — or standalone for CI/CD.

Learn more →
02

Test-driven documentation

Generate specs as a side-effect of your Ginkgo integration tests. Real HTTP requests mean zero drift.

Learn more →
03

Multiple UI providers

Swagger UI, Stoplight, ReDoc, Scalar, or RapiDoc. Switch providers by changing a single import. CDN or air-gapped.

Learn more →
04

Built-in spec validation

Error, Warning, and Info severity levels. Catch missing fields, invalid references, and best-practice violations before deployment.

Learn more →

From zero to a working OpenAPI spec in three steps.

1

Install

go get github.com/oaswrap/spec

No code generation. No annotations.

2

Define routes

r := spec.NewRouter(
  option.WithTitle("My API"),
)
r.Get("/users/{id}",
  option.Response(200, new(User)),
)

Works with chi, gin, echo, fiber, net/http.

3

Generate spec

r.WriteSchemaTo("openapi.yaml")

CI-ready. Plug into any UI provider.

Start shipping accurate API docs today.

Zero annotations. Zero drift. Just Go code and tests that already exist.

© 2026 OASWrap — built with Docusaurus