diff --git a/swagger.go b/swagger.go index b8dc937..0d2d1c2 100644 --- a/swagger.go +++ b/swagger.go @@ -15,13 +15,15 @@ import ( // Config stores echoSwagger configuration variables. type Config struct { // The url pointing to API definition (normally swagger.json or swagger.yaml). Default is `mockedSwag.json`. - URLs []string - DocExpansion string - DomID string - InstanceName string - DeepLinking bool - PersistAuthorization bool - SyntaxHighlight bool + URLs []string + DocExpansion string + DomID string + InstanceName string + DefaultModelsExpandDepth int + DeepLinking bool + PersistAuthorization bool + SyntaxHighlight bool + TryItOutEnabled bool // The information for OAuth2 integration, if any. OAuth *OAuthConfig @@ -90,6 +92,24 @@ func PersistAuthorization(persistAuthorization bool) func(*Config) { } } +// DefaultModelsExpandDepth expansion depth for models (set -1 to +// completely hide the models). +// Defaults to 1 +func DefaultModelsExpandDepth(depth int) func(*Config) { + return func(c *Config) { + c.DefaultModelsExpandDepth = depth + } +} + +// TryItOutEnabled controls whether the "Try it out" section should be +// enabled by default. +// Defaults to true +func TryItOutEnabled(enable bool) func(*Config) { + return func(c *Config) { + c.TryItOutEnabled = enable + } +} + func OAuth(config *OAuthConfig) func(*Config) { return func(c *Config) { c.OAuth = config @@ -98,13 +118,15 @@ func OAuth(config *OAuthConfig) func(*Config) { func newConfig(configFns ...func(*Config)) *Config { config := Config{ - URLs: []string{"doc.json", "doc.yaml"}, - DocExpansion: "list", - DomID: "swagger-ui", - InstanceName: "swagger", - DeepLinking: true, - PersistAuthorization: false, - SyntaxHighlight: true, + URLs: []string{"doc.json", "doc.yaml"}, + DocExpansion: "list", + DomID: "swagger-ui", + InstanceName: "swagger", + DefaultModelsExpandDepth: 1, + DeepLinking: true, + PersistAuthorization: false, + SyntaxHighlight: true, + TryItOutEnabled: true, } for _, fn := range configFns { @@ -268,6 +290,26 @@ const indexTemplate = `