swaggerui

package
v1.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package swaggerui serves a vendored copy of Swagger UI.

Swagger UI (https://github.com/swagger-api/swagger-ui) is distributed under the Apache License 2.0, see dist/LICENSE and dist/NOTICE.

The package depends on the standard library only, so importing it from generated code does not add any third-party dependencies to the resulting binary.

Index

Constants

View Source
const Version = "5.33.2"

Version is the version of the vendored swagger-ui-dist package.

Variables

This section is empty.

Functions

func Assets

func Assets() fs.FS

Assets returns the embedded swagger-ui-dist files.

Types

type Config

type Config struct {
	// SpecURL is the URL of the OpenAPI document to render.
	//
	// A relative URL is resolved by the browser against the page URL,
	// so "openapi.json" works wherever the handler is mounted.
	SpecURL string
	// Title is the HTML page title. Defaults to "Swagger UI".
	Title string
	// AssetsURL is the base URL (with a trailing slash) to load Swagger UI
	// static files from, for example a CDN like "https://unpkg.com/swagger-ui-dist@5/".
	//
	// If empty, the files embedded into this package are served by Handler.
	AssetsURL string
}

Config configures Handler.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler serves Swagger UI: the index page at "/" (or "") and, unless Config.AssetsURL is set, static files at "/<name>".

Paths are relative to the mount point: use http.StripPrefix to mount the handler under a sub-path.

func New

func New(cfg Config) *Handler

New creates a new Handler.

func (*Handler) Match

func (h *Handler) Match(p string) bool

Match reports whether ServeHTTP would serve given path.

The path must be relative to the mount point, i.e. "/" for the index page.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL