swagger

package
v3.1.19 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WrapHandler = Handler()

WrapHandler wraps swaggerFiles.Handler and returns http.HandlerFunc.

Functions

func AfterScript

func AfterScript(js string) func(*Config)

AfterScript holds JavaScript to be run right after the Swagger UI object is created and set on the window.

func BeforeScript

func BeforeScript(js string) func(*Config)

BeforeScript holds JavaScript to be run right before the Swagger UI object is created.

func DeepLinking

func DeepLinking(deepLinking bool) func(*Config)

DeepLinking true, false.

func DefaultModelsExpandDepth

func DefaultModelsExpandDepth(defaultModelsExpandDepth ModelsExpandDepthType) func(*Config)

DefaultModelsExpandDepth presents the model of response and request. set the default expansion depth for models

func DocExpansion

func DocExpansion(docExpansion string) func(*Config)

DocExpansion list, full, none.

func DomID

func DomID(domID string) func(*Config)

DomID #swagger-ui.

func Handler

func Handler(configFns ...func(*Config)) core.HandlerFunc

Handler wraps `http.Handler` into `http.HandlerFunc`.

func InstanceName

func InstanceName(name string) func(*Config)

InstanceName set the instance name that was used to generate the swagger documents Defaults to swag.Name ("swagger").

func Layout

func Layout(layout SwaggerLayout) func(*Config)

Define Layout options are BaseLayout or StandaloneLayout

func PersistAuthorization

func PersistAuthorization(persistAuthorization bool) func(*Config)

PersistAuthorization Persist authorization information over browser close/refresh. Defaults to false.

func Plugins

func Plugins(plugins []string) func(*Config)

Plugins specifies additional plugins to load into Swagger UI.

func ShowExtensions

func ShowExtensions(showExtensions bool) func(config *Config)

ShowExtensions controls the display of vendor extension (x-) fields and values for Operations, Parameters, Responses, and Schema.

func UIConfig

func UIConfig(props map[string]string) func(*Config)

UIConfig specifies additional SwaggerUIBundle config object properties. UIConfig returns a function that configures the swagger UI with custom properties. The input props map is converted to use template.JS type for both keys and values to ensure safe usage in HTML templates. The returned function sets these properties in the provided Config's UIConfig field.

func URL

func URL(url string) func(*Config)

URL presents the url pointing to API definition (normally swagger.json or swagger.yaml).

Types

type Config

type Config struct {
	// The url pointing to API definition (normally swagger.json or swagger.yaml). Default is `doc.json`.
	URL                      string
	DocExpansion             string
	DomID                    string
	InstanceName             string
	BeforeScript             template.JS
	AfterScript              template.JS
	Plugins                  []template.JS
	UIConfig                 map[template.JS]template.JS
	DeepLinking              bool
	PersistAuthorization     bool
	Layout                   SwaggerLayout
	DefaultModelsExpandDepth ModelsExpandDepthType
	ShowExtensions           bool
	Dir                      string
}

Config stores httpSwagger configuration variables.

type ModelsExpandDepthType

type ModelsExpandDepthType int
const (
	ShowModel ModelsExpandDepthType = 1
	HideModel ModelsExpandDepthType = -1
)

type SwaggerLayout

type SwaggerLayout string
const (
	BaseLayout       SwaggerLayout = "BaseLayout"
	StandaloneLayout SwaggerLayout = "StandaloneLayout"
)

Jump to

Keyboard shortcuts

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