Skip to content

/docs does not work offline: allow a configurable swagger-ui asset URL #1061

Description

@lbellows

Split out of #1053. That issue is now SRI and version only, fixed by #1060.

/docs loads swagger-ui's CSS and JS from cdnjs. On an air-gapped or LAN-only install the page stays blank. The rest of the web UI is embedded with go:embed, so /docs is the only page that needs internet access.

Bundling swagger-ui-dist was turned down in #114 because of binary size (about 1.5 MB gzipped), and so were build tags. This proposal needs neither.

Proposal: an optional setting for where /docs loads the swagger-ui assets from, e.g. GOTIFY_SERVER_SWAGGERUIURL / server.swaggeruiurl in config.yml. It defaults to the current cdnjs path. docs/ui.go would put the setting in front of the three filenames and keep the same integrity hashes. A local mirror would then have to serve byte-identical files for the pinned version, so a changed or wrong-version mirror fails closed rather than running in the app origin.

  • No change to binary size or default behaviour.
  • An offline user runs something like npm pack swagger-ui-dist@<pinned> once, hosts the three files on any internal static server (or a reverse proxy path) and sets the URL.
  • About ten lines in docs/ui.go plus a config field.

Workaround until then: /swagger still serves the spec JSON, so an offline Swagger/OpenAPI viewer can load it directly.

If you're open to it I can send the PR or just close this if its still off the table.

Activity

  1. jmattheis commented on Sep 30, 2026

    @jmattheis
    Member

    I'm not sure if offline use is really needed here. If this is implemented via a feature flag I'd expect this to be used by a really low amount of people, so I don't think this is worth supporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:featureNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions