From 75b6801446f941e6418800b92254ae1b4fbc2aff Mon Sep 17 00:00:00 2001 From: Felipe Puentes Date: Thu, 26 Jan 2023 12:05:20 -0500 Subject: [PATCH 1/2] Creating Method to modify the layout --- swagger.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/swagger.go b/swagger.go index 5eb250d..74cb039 100644 --- a/swagger.go +++ b/swagger.go @@ -27,6 +27,7 @@ type Config struct { UIConfig map[template.JS]template.JS DeepLinking bool PersistAuthorization bool + Layout string } // URL presents the url pointing to API definition (normally swagger.json or swagger.yaml). @@ -110,6 +111,19 @@ func AfterScript(js string) func(*Config) { } } +type Layouts string +const ( + BaseLayout Layouts = "BaseLayout" + StandaloneLayout Layouts = "StandaloneLayout" +) + +// Define Layout options are BaseLayout or StandaloneLayout +func Layout(layout Layouts) func(*Config) { + return func(c *Config) { + c.Layout = string(layout) + } +} + func newConfig(configFns ...func(*Config)) *Config { config := Config{ URL: "doc.json", @@ -118,6 +132,7 @@ func newConfig(configFns ...func(*Config)) *Config { InstanceName: "swagger", DeepLinking: true, PersistAuthorization: false, + Layout: string(StandaloneLayout), } for _, fn := range configFns { @@ -285,7 +300,7 @@ window.onload = function() { {{- range $k, $v := .UIConfig}} {{$k}}: {{$v}}, {{- end}} - layout: "StandaloneLayout" + layout: "{{$.Layout}}" }) window.ui = ui From e4e7ec50b97d5f12345c1f045f8ef88144db5b34 Mon Sep 17 00:00:00 2001 From: Felipe Puentes Date: Thu, 26 Jan 2023 12:10:22 -0500 Subject: [PATCH 2/2] Fixing spacing --- swagger.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swagger.go b/swagger.go index 74cb039..71a7136 100644 --- a/swagger.go +++ b/swagger.go @@ -27,7 +27,7 @@ type Config struct { UIConfig map[template.JS]template.JS DeepLinking bool PersistAuthorization bool - Layout string + Layout string } // URL presents the url pointing to API definition (normally swagger.json or swagger.yaml). @@ -132,7 +132,7 @@ func newConfig(configFns ...func(*Config)) *Config { InstanceName: "swagger", DeepLinking: true, PersistAuthorization: false, - Layout: string(StandaloneLayout), + Layout: string(StandaloneLayout), } for _, fn := range configFns {