Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ func main() {
| DocExpansion | string | "list" | Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing). |
| DeepLinking | bool | true | If set to true, enables deep linking for tags and operations. See the Deep Linking documentation for more information. |
| DefaultModelsExpandDepth | int | 1 | Default expansion depth for models (set to -1 completely hide the models). |
| DefaultModelExpandDepth | int | 1 | Default expansion depth for the model on the model-example section. |
| DefaultModelRendering | string | "example" | Controls how the model is shown when the API is first rendered. "example" or "model". (The user can always switch the rendering for a given model by clicking the 'Model' and 'Example Value' links.) |
| InstanceName | string | "swagger" | The instance name of the swagger document. If multiple different swagger instances should be deployed on one gin router, ensure that each instance has a unique name (use the _--instanceName_ parameter to generate swagger documents with _swag init_). |
| PersistAuthorization | bool | false | If set to true, it persists authorization data and it would not be lost on browser close/refresh. |
| Oauth2DefaultClientID | string | "" | If set, it's used to prepopulate the _client_id_ field of the OAuth2 Authorization dialog. |
Expand Down
12 changes: 11 additions & 1 deletion swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type swaggerConfig struct {
Title string
Oauth2RedirectURL htmlTemplate.JS
DefaultModelsExpandDepth int
DefaultModelExpandDepth int
DefaultModelRendering string
DeepLinking bool
PersistAuthorization bool
Oauth2DefaultClientID string
Expand All @@ -35,6 +37,8 @@ type Config struct {
InstanceName string
Title string
DefaultModelsExpandDepth int
DefaultModelExpandDepth int
DefaultModelRendering string
DeepLinking bool
PersistAuthorization bool
Oauth2DefaultClientID string
Expand All @@ -47,6 +51,8 @@ func (config Config) toSwaggerConfig() swaggerConfig {
DeepLinking: config.DeepLinking,
DocExpansion: config.DocExpansion,
DefaultModelsExpandDepth: config.DefaultModelsExpandDepth,
DefaultModelExpandDepth: config.DefaultModelExpandDepth,
DefaultModelRendering: config.DefaultModelRendering,
Oauth2RedirectURL: "`${window.location.protocol}//${window.location.host}$" +
"{window.location.pathname.split('/').slice(0, window.location.pathname.split('/').length - 1).join('/')}" +
"/oauth2-redirect.html`",
Expand Down Expand Up @@ -126,6 +132,8 @@ func WrapHandler(handler *webdav.Handler, options ...func(*Config)) gin.HandlerF
InstanceName: swag.Name,
Title: "Swagger UI",
DefaultModelsExpandDepth: 1,
DefaultModelExpandDepth: 1,
DefaultModelRendering: "example",
DeepLinking: true,
PersistAuthorization: false,
Oauth2DefaultClientID: "",
Expand Down Expand Up @@ -280,7 +288,9 @@ window.onload = function() {
layout: "StandaloneLayout",
docExpansion: "{{.DocExpansion}}",
deepLinking: {{.DeepLinking}},
defaultModelsExpandDepth: {{.DefaultModelsExpandDepth}}
defaultModelsExpandDepth: {{.DefaultModelsExpandDepth}},
defaultModelExpandDepth: {{.DefaultModelExpandDepth}},
defaultModelRendering: "{{.DefaultModelRendering}}"
})

const defaultClientId = "{{.Oauth2DefaultClientID}}";
Expand Down