File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -16,10 +16,11 @@ import (
16
16
// Config stores echoSwagger configuration variables.
17
17
type Config struct {
18
18
// The url pointing to API definition (normally swagger.json or swagger.yaml). Default is `mockedSwag.json`.
19
- URL string
20
- DeepLinking bool
21
- DocExpansion string
22
- DomID string
19
+ URL string
20
+ DeepLinking bool
21
+ DocExpansion string
22
+ DomID string
23
+ PersistAuthorization bool
23
24
}
24
25
25
26
// URL presents the url pointing to API definition (normally swagger.json or swagger.yaml).
@@ -50,6 +51,14 @@ func DomID(domID string) func(c *Config) {
50
51
}
51
52
}
52
53
54
+ // If set to true, it persists authorization data and it would not be lost on browser close/refresh
55
+ // Defaults to false
56
+ func PersistAuthorization (persistAuthorization bool ) func (c * Config ) {
57
+ return func (c * Config ) {
58
+ c .PersistAuthorization = persistAuthorization
59
+ }
60
+ }
61
+
53
62
// WrapHandler wraps swaggerFiles.Handler and returns echo.HandlerFunc
54
63
var WrapHandler = FiberWrapHandler ()
55
64
@@ -196,6 +205,7 @@ window.onload = function() {
196
205
deepLinking: {{.DeepLinking}},
197
206
docExpansion: "{{.DocExpansion}}",
198
207
dom_id: "{{.DomID}}",
208
+ persistAuthorization: {{.PersistAuthorization}},
199
209
validatorUrl: null,
200
210
presets: [
201
211
SwaggerUIBundle.presets.apis,
Original file line number Diff line number Diff line change @@ -307,3 +307,11 @@ func TestDomID(t *testing.T) {
307
307
configFunc (& cfg )
308
308
assert .Equal (t , expected , cfg .DomID )
309
309
}
310
+
311
+ func TestPersistAuthorization (t * testing.T ) {
312
+ expected := true
313
+ cfg := Config {}
314
+ configFunc := PersistAuthorization (expected )
315
+ configFunc (& cfg )
316
+ assert .Equal (t , expected , cfg .PersistAuthorization )
317
+ }
You can’t perform that action at this time.
0 commit comments