Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Config struct {
DeepLinking bool
DocExpansion string
DomID string
RedirectUrl interface{}
Comment thread
ubogdan marked this conversation as resolved.
Outdated
}

// URL presents the url pointing to API definition (normally swagger.json or swagger.yaml).
Expand Down Expand Up @@ -50,6 +51,13 @@ func DomID(domID string) func(c *Config) {
}
}

// Redirect URL for oauth2-redirect
func RedirectUrl(redirectUrl string) func(c *Config) {
return func(c *Config) {
c.RedirectUrl = redirectUrl
}
}

// WrapHandler wraps swaggerFiles.Handler and returns echo.HandlerFunc
var WrapHandler = EchoWrapHandler()

Expand All @@ -62,6 +70,7 @@ func EchoWrapHandler(configFns ...func(c *Config)) echo.HandlerFunc {
DeepLinking: true,
DocExpansion: "list",
DomID: "#swagger-ui",
RedirectUrl: nil,
Comment thread
ubogdan marked this conversation as resolved.
Outdated
}

for _, configFn := range configFns {
Expand Down Expand Up @@ -208,6 +217,9 @@ window.onload = function() {
docExpansion: "{{.DocExpansion}}",
dom_id: "{{.DomID}}",
validatorUrl: null,
{{if .RedirectUrl}}
oauth2RedirectUrl: {{.RedirectUrl}},
{{end}}
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
Expand Down