Skip to content

Commit 1f40b78

Browse files
authored
feat: option to chose for swagger layout (#87)
* Creating Method to modify the layout * Fixing spacing
1 parent c8d62bf commit 1f40b78

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

swagger.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type Config struct {
2727
UIConfig map[template.JS]template.JS
2828
DeepLinking bool
2929
PersistAuthorization bool
30+
Layout string
3031
}
3132

3233
// URL presents the url pointing to API definition (normally swagger.json or swagger.yaml).
@@ -110,6 +111,19 @@ func AfterScript(js string) func(*Config) {
110111
}
111112
}
112113

114+
type Layouts string
115+
const (
116+
BaseLayout Layouts = "BaseLayout"
117+
StandaloneLayout Layouts = "StandaloneLayout"
118+
)
119+
120+
// Define Layout options are BaseLayout or StandaloneLayout
121+
func Layout(layout Layouts) func(*Config) {
122+
return func(c *Config) {
123+
c.Layout = string(layout)
124+
}
125+
}
126+
113127
func newConfig(configFns ...func(*Config)) *Config {
114128
config := Config{
115129
URL: "doc.json",
@@ -118,6 +132,7 @@ func newConfig(configFns ...func(*Config)) *Config {
118132
InstanceName: "swagger",
119133
DeepLinking: true,
120134
PersistAuthorization: false,
135+
Layout: string(StandaloneLayout),
121136
}
122137

123138
for _, fn := range configFns {
@@ -285,7 +300,7 @@ window.onload = function() {
285300
{{- range $k, $v := .UIConfig}}
286301
{{$k}}: {{$v}},
287302
{{- end}}
288-
layout: "StandaloneLayout"
303+
layout: "{{$.Layout}}"
289304
})
290305
291306
window.ui = ui

0 commit comments

Comments
 (0)