Back to directory

go-apispec: Generate OpenAPI from Go code

A command-line tool that statically analyzes Go source code and generates an OpenAPI 3.1 spec, auto-detecting the web framework in use and following the call graph from routes to handlers to infer request and response types.

go-apispec: Generate OpenAPI from Go code

go-apispec points at a Go module, detects which web framework it uses, and follows the call graph from each route to its handler to infer the request body, parameters and response types, without needing annotations in the source. It generates the spec as YAML or JSON.

It supports Chi, Gin, Echo, Fiber, Gorilla Mux and net/http, including their route parameter styles, request-body binding calls and response-writing calls, and correctly normalizes each router's own path-template syntax, such as gorilla/mux's regex constraints or Go 1.22's ServeMux method-prefix patterns, into OpenAPI path placeholders. Projects using more than one framework at once are supported, with routes from every detected framework appearing together in one spec.

It also infers a response's content type from explicit header-setting calls, with a fallback for dynamic content types, and detects response writes made through fmt.Fprintf, io.Copy and io.WriteString in every supported framework.

More in APIs

See all 103
  • Grabbit

    grabbit.live

    An agent-first screenshot API that captures a hosted, pixel-perfect image of any URL through a one-line CLI, a hosted MCP server, or a plain REST call.

  • App2Api

    app2api.com

    A tool that reverse-engineers the real API behind a mobile app you own or are authorized to test, then hands an AI agent a runnable call and an OpenAPI spec for it.

  • Apitomy Codegen

    github.com

    Generates JAX-RS server stubs, Quarkus-optimized applications, data models and client libraries from OpenAPI specifications.