Skip to content

Migration: pkg/openapigo/transport-openapi

The OpenAPI-spec + Stoplight Elements docs handler — Register, Option, WithSpecPath, WithDocsPath, WithTitle, WithSecurityHeaderOptions, WithoutSecurityHeaders — has moved verbatim into the standalone companion module gitlab.com/phpboyscout/go/transport-openapi (v0.1.0). The API is identical; only the import path changes.

GTB never consumed pkg/openapi itself (it was a downstream-facing feature), so GTB's own cut-over was a pure deletion — there is no adapter or facade. If your tool imported it, repoint:

// before
import "gitlab.com/phpboyscout/go-tool-base/pkg/openapi"

// after (the package name is still `openapi`; alias for clarity)
import openapi "gitlab.com/phpboyscout/go/transport-openapi"

Nothing else changes:

openapi.Register(mux, spec, openapi.WithTitle("Widget API"))

Add the dependency:

go get gitlab.com/phpboyscout/go/[email protected]

Why it moved — and why a companion, not part of go/transport

pkg/openapi mounts on a transport server's mux and uses go/transport's security-header middleware, so it belongs to the transport world. It is a separate companion module rather than part of go/transport core because it embeds the Stoplight Elements UI — ~2.4 MB of //go:embed-ed JS/CSS. Folding that into the core would add 2.4 MB to every transport-server binary, even those that serve no API docs. As a companion, only a tool that imports go/transport-openapi pays for the embed.

transport-openapi v0.1.x targets go/transport v0.1.x (and go/transit v0.1.x); keep them at matching minors. Docs live at transport-openapi.go.phpboyscout.uk.