Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added RedirectUrl into swagger.go to enable custom redirect URL #67

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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{}
ubogdan marked this conversation as resolved.
Show resolved Hide resolved
}

// 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,
ubogdan marked this conversation as resolved.
Show resolved Hide resolved
}

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