Skip to content

OpenAPI

Serving an OpenAPI specification and an interactive Stoplight Elements docs site (with a "try it" console) from a single Register(mux, spec, opts...) call now lives in the standalone module gitlab.com/phpboyscout/go/transport-openapi.

It is a companion to go/transport, not part of its core: the Stoplight Elements distribution it embeds is ~2.4 MB, so keeping it a separate import means only tools that actually serve API docs pay for the embed. The handler mounts on any *http.ServeMux and wraps its routes with go/transport's security-header middleware by default.

import openapi "gitlab.com/phpboyscout/go/transport-openapi"

// GET /openapi.yaml -> the spec ; GET /docs/ -> the Stoplight UI
if err := openapi.Register(mux, spec, openapi.WithTitle("Widget API")); err != nil {
    return err
}

GTB itself does not consume this module — it is a downstream-facing feature for tools built on GTB. Import it directly alongside go/transport.