GoModel can serve an interactive Swagger UI at /swagger/index.html. It is
opt-in at two levels: the binary must be compiled with the swagger build tag,
and SWAGGER_ENABLED must be set at runtime.
Why it is not in the default build
Release binaries and the official Docker image are built without the
swagger tag. The embedded spec and UI assets add over 30 MB to the binary
(roughly 55 MB to 88 MB on an unstripped build) and therefore to the image, and
the endpoint is rarely needed in production. Leaving it out keeps the artifacts
small and the exposed surface minimal.
If you only need the API spec, use the checked-in
docs/openapi.json
in any OpenAPI viewer instead.
Build with Swagger
make run builds with the tag and enables the UI automatically for local
development.
Enable at runtime
Or in config.yaml:
/swagger/* bypasses GOMODEL_MASTER_KEY and gateway API key authentication,
so enabling it publishes interactive API documentation to anyone who can reach
the server. Enable it only in development or trusted environments, or restrict
the path at the network layer.
The UI respects BASE_PATH. If SWAGGER_ENABLED=true is set on a binary built
without the tag, GoModel logs a warning at startup and serves nothing at
/swagger/*.
Regenerate the spec
Run make swagger after changing API annotations to regenerate the embedded
docs package and docs/openapi.json. See
DEVELOPMENT.md
for details.