Skip to content

Commit 45b6a78

Browse files
authored
Merge pull request #326 from waterlinked/master
add DefaultModelExpandDepth and DefaultModelRendering to Config
2 parents 92bd8fe + 36b13ec commit 45b6a78

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ func main() {
201201
| 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). |
202202
| DeepLinking | bool | true | If set to true, enables deep linking for tags and operations. See the Deep Linking documentation for more information. |
203203
| DefaultModelsExpandDepth | int | 1 | Default expansion depth for models (set to -1 completely hide the models). |
204+
| DefaultModelExpandDepth | int | 1 | Default expansion depth for the model on the model-example section. |
205+
| 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.) |
204206
| 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_). |
205207
| PersistAuthorization | bool | false | If set to true, it persists authorization data and it would not be lost on browser close/refresh. |
206208
| Oauth2DefaultClientID | string | "" | If set, it's used to prepopulate the _client_id_ field of the OAuth2 Authorization dialog. |

swagger.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ type swaggerConfig struct {
2121
Title string
2222
Oauth2RedirectURL htmlTemplate.JS
2323
DefaultModelsExpandDepth int
24+
DefaultModelExpandDepth int
25+
DefaultModelRendering string
2426
DeepLinking bool
2527
PersistAuthorization bool
2628
Oauth2DefaultClientID string
@@ -35,6 +37,8 @@ type Config struct {
3537
InstanceName string
3638
Title string
3739
DefaultModelsExpandDepth int
40+
DefaultModelExpandDepth int
41+
DefaultModelRendering string
3842
DeepLinking bool
3943
PersistAuthorization bool
4044
Oauth2DefaultClientID string
@@ -47,6 +51,8 @@ func (config Config) toSwaggerConfig() swaggerConfig {
4751
DeepLinking: config.DeepLinking,
4852
DocExpansion: config.DocExpansion,
4953
DefaultModelsExpandDepth: config.DefaultModelsExpandDepth,
54+
DefaultModelExpandDepth: config.DefaultModelExpandDepth,
55+
DefaultModelRendering: config.DefaultModelRendering,
5056
Oauth2RedirectURL: "`${window.location.protocol}//${window.location.host}$" +
5157
"{window.location.pathname.split('/').slice(0, window.location.pathname.split('/').length - 1).join('/')}" +
5258
"/oauth2-redirect.html`",
@@ -126,6 +132,8 @@ func WrapHandler(handler *webdav.Handler, options ...func(*Config)) gin.HandlerF
126132
InstanceName: swag.Name,
127133
Title: "Swagger UI",
128134
DefaultModelsExpandDepth: 1,
135+
DefaultModelExpandDepth: 1,
136+
DefaultModelRendering: "example",
129137
DeepLinking: true,
130138
PersistAuthorization: false,
131139
Oauth2DefaultClientID: "",
@@ -286,7 +294,9 @@ window.onload = function() {
286294
layout: "StandaloneLayout",
287295
docExpansion: "{{.DocExpansion}}",
288296
deepLinking: {{.DeepLinking}},
289-
defaultModelsExpandDepth: {{.DefaultModelsExpandDepth}}
297+
defaultModelsExpandDepth: {{.DefaultModelsExpandDepth}},
298+
defaultModelExpandDepth: {{.DefaultModelExpandDepth}},
299+
defaultModelRendering: "{{.DefaultModelRendering}}"
290300
})
291301
292302
const defaultClientId = "{{.Oauth2DefaultClientID}}";

0 commit comments

Comments
 (0)