Skip to main content

Adapters Overview

Framework adapters provide seamless integration with popular Go web frameworks. Each adapter:

  • Automatically generates an OpenAPI spec from your route definitions
  • Serves interactive documentation UI at /docs
  • Serves the OpenAPI YAML spec at /docs/openapi.yaml
  • Supports inline OpenAPI options alongside route handlers

Available Adapters

FrameworkAdapter ModuleDescription
Chigithub.com/oaswrap/spec/adapter/chiopenapiLightweight router with middleware support
Echo v4github.com/oaswrap/spec/adapter/echoopenapiHigh performance, extensible, minimalist framework
Echo v5github.com/oaswrap/spec/adapter/echov5openapiEcho v5 with updated Context API
Gingithub.com/oaswrap/spec/adapter/ginopenapiFast HTTP web framework with zero allocation router
Fiber v2github.com/oaswrap/spec/adapter/fiberopenapiExpress-inspired framework built on Fasthttp
Fiber v3github.com/oaswrap/spec/adapter/fiberv3openapiFiber v3 with updated Ctx interface and binding API
net/httpgithub.com/oaswrap/spec/adapter/httpopenapiGo standard library HTTP package
HTTPRoutergithub.com/oaswrap/spec/adapter/httprouteropenapiHigh performance HTTP request router
Gorilla Muxgithub.com/oaswrap/spec/adapter/muxopenapiPowerful HTTP router and URL matcher

How Adapters Work

Each adapter wraps both your framework's router and spec.Generator:

  1. NewRouter(frameworkRouter, opts...) returns the adapter's Generator interface
  2. Route methods (.Get(), .Post(), etc.) register handlers on both the framework router and the spec generator
  3. The docs UI (/docs) and YAML spec (/docs/openapi.yaml) routes are added automatically
  4. Path parameter styles are converted — e.g., :id{id} for OpenAPI

Disable Automatic Docs

If you want to manage the docs routes yourself:

api := chiopenapi.NewRouter(r,
option.WithTitle("My API"),
option.DisableDocs(),
)

Default Adapter Settings

All adapters come with sensible defaults:

  • Title: "API Documentation"
  • OpenAPI version: 3.0.3
  • Docs path: /docs
  • Spec path: /docs/openapi.yaml
  • UI provider: Stoplight Elements