swagger

package
v0.0.0-...-0f3da70 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IndexTpl

func IndexTpl(assetsBase, faviconBase string, cfg *Config) string

IndexTpl creates page template.

Types

type Config

type Config struct {
	Title       string `json:"title"`          // Title of index file.
	SwaggerJSON string `json:"swaggerJsonUrl"` // URL to openapi.json/swagger.json document specification.
	BasePath    string `json:"basePath"`       // Base URL to docs.

	ShowTopBar         bool              `json:"showTopBar"`         // Show navigation top bar, hidden by default.
	HideCurl           bool              `json:"hideCurl"`           // Hide curl code snippet.
	JsonEditor         bool              `json:"jsonEditor"`         // Enable visual json editor support (experimental, can fail with complex schemas).
	PreAuthorizeApiKey map[string]string `json:"preAuthorizeApiKey"` // Map of security name to key value.

	// SettingsUI contains keys and plain javascript values of SwaggerUIBundle configuration.
	// Overrides default values.
	// See https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/ for available options.
	SettingsUI map[string]string `json:"-"`

	LocalOpenApiFile string `json:"-"`
	OpenApiData      []byte `json:"-"`
	OpenApiDataType  string `json:"-"`
}

Config is used for Swagger UI handler configuration.

func NewConfig

func NewConfig() *Config

type Handler

type Handler struct {
	*Config

	ConfigJson template.JS
	// contains filtered or unexported fields
}

Handler handles swagger UI request.

func NewHandlerWithConfig

func NewHandlerWithConfig(config *Config, assetsBase, faviconBase string, staticServer http.Handler) *Handler

NewHandlerWithConfig returns a HTTP handler for swagger UI.

func (*Handler) ServeHTTP

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

ServeHTTP implements http.Handler interface to handle swagger UI request.

Jump to

Keyboard shortcuts

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