diff --git a/swagger.go b/swagger.go index 4e08c8c..3b7bed1 100644 --- a/swagger.go +++ b/swagger.go @@ -22,6 +22,7 @@ type Config struct { InstanceName string DeepLinking bool PersistAuthorization bool + SyntaxHighlight bool // The information for OAuth2 integration, if any. OAuth *OAuthConfig @@ -54,6 +55,13 @@ func DeepLinking(deepLinking bool) func(*Config) { } } +// SyntaxHighlight true, false. +func SyntaxHighlight(syntaxHighlight bool) func(*Config) { + return func(c *Config) { + c.SyntaxHighlight = syntaxHighlight + } +} + // DocExpansion list, full, none. func DocExpansion(docExpansion string) func(*Config) { return func(c *Config) { @@ -97,6 +105,7 @@ func newConfig(configFns ...func(*Config)) *Config { InstanceName: "swagger", DeepLinking: true, PersistAuthorization: false, + SyntaxHighlight: true, } for _, fn := range configFns { @@ -257,6 +266,7 @@ window.onload = function() { // Build a system const ui = SwaggerUIBundle({ url: "{{.URL}}", + syntaxHighlight: {{.SyntaxHighlight}}, deepLinking: {{.DeepLinking}}, docExpansion: "{{.DocExpansion}}", persistAuthorization: {{.PersistAuthorization}}, diff --git a/swagger_test.go b/swagger_test.go index 5e42c94..5fcfd69 100644 --- a/swagger_test.go +++ b/swagger_test.go @@ -374,6 +374,13 @@ func TestDeepLinking(t *testing.T) { assert.Equal(t, expected, cfg.DeepLinking) } +func TestSyntaxHighlight(t *testing.T) { + var cfg Config + expected := true + SyntaxHighlight(expected)(&cfg) + assert.Equal(t, expected, cfg.SyntaxHighlight) +} + func TestDocExpansion(t *testing.T) { var cfg Config expected := "https://github.com/swaggo/docs"