1
+ package org .springdoc .core ;
2
+
3
+
4
+ import org .apache .commons .lang3 .StringUtils ;
5
+ import org .springframework .boot .context .properties .ConfigurationProperties ;
6
+ import org .springframework .context .annotation .Configuration ;
7
+
8
+ import java .util .Map ;
9
+ import java .util .TreeMap ;
10
+
11
+ /**
12
+ * Please refer to https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md
13
+ * to get the idea what each parameter does.
14
+ */
15
+ @ Configuration
16
+ @ ConfigurationProperties (prefix = "springdoc.swagger-ui" )
17
+ public class SwaggerUiConfig {
18
+ // URL to fetch external configuration document from.
19
+ private String configUrl ;
20
+ // The url pointing to API definition (normally
21
+ // swagger.json/swagger.yaml/openapi.json/openapi.yaml).
22
+ private String url ;
23
+ // If set, enables filtering. The top bar will show an edit box that
24
+ // could be used to filter the tagged operations that are shown.
25
+ private String filter ;
26
+
27
+ // Enables or disables deep linking for tags and operations.
28
+ private Boolean deepLinking ;
29
+ // Controls the display of operationId in operations list.
30
+ private Boolean displayOperationId ;
31
+ // The default expansion depth for models (set to -1 completely hide the models).
32
+ private Integer defaultModelsExpandDepth ;
33
+ // The default expansion depth for the model on the model-example section.
34
+ private Integer defaultModelExpandDepth ;
35
+
36
+ // Controls how the model is shown when the API is first rendered.
37
+ private String defaultModelRendering ;
38
+ // Controls the display of the request duration (in milliseconds) for Try-It-Out requests.
39
+ private Boolean displayRequestDuration ;
40
+ // Controls the default expansion setting for the operations and tags.
41
+ private String docExpansion ;
42
+ // If set, limits the number of tagged operations displayed to at most this many.
43
+ private Integer maxDisplayedTags ;
44
+ // Controls the display of vendor extension (x-) fields and values.
45
+ private Boolean showExtensions ;
46
+ // Controls the display of extensions
47
+ private Boolean showCommonExtensions ;
48
+ // Set a different validator URL, for example for locally deployed validators
49
+ private String validatorUrl ;
50
+
51
+ public Map <String , String > getConfigParameters () {
52
+ final Map <String , String > params = new TreeMap <>();
53
+ put ("url" , url , params );
54
+ put ("configUrl" , configUrl , params );
55
+ put ("filter" , filter , params );
56
+ put ("deepLinking" , this .deepLinking , params );
57
+ put ("displayOperationId" , displayOperationId , params );
58
+ put ("defaultModelsExpandDepth" , defaultModelsExpandDepth , params );
59
+ put ("defaultModelExpandDepth" , defaultModelExpandDepth , params );
60
+ put ("defaultModelRendering" , defaultModelRendering , params );
61
+ put ("displayRequestDuration" , displayRequestDuration , params );
62
+ put ("docExpansion" , docExpansion , params );
63
+ put ("maxDisplayedTags" , maxDisplayedTags , params );
64
+ put ("showExtensions" , showExtensions , params );
65
+ put ("showCommonExtensions" , showCommonExtensions , params );
66
+ put ("validatorUrl" , validatorUrl , params );
67
+ return params ;
68
+ }
69
+
70
+ protected void put (final String name , final Integer value , final Map <String , String > params ) {
71
+ if (value != null ) {
72
+ params .put (name , value .toString ());
73
+ }
74
+ }
75
+
76
+ protected void put (final String name , final Boolean value , final Map <String , String > params ) {
77
+ if (value != null ) {
78
+ params .put (name , value .toString ());
79
+ }
80
+ }
81
+
82
+ protected void put (final String name , final String value , final Map <String , String > params ) {
83
+ if (!StringUtils .isEmpty (value )) {
84
+ params .put (name , value );
85
+ }
86
+ }
87
+
88
+ public String getConfigUrl () {
89
+ return configUrl ;
90
+ }
91
+
92
+ public void setConfigUrl (String configUrl ) {
93
+ this .configUrl = configUrl ;
94
+ }
95
+
96
+ public String getUrl () {
97
+ return url ;
98
+ }
99
+
100
+ public void setUrl (String url ) {
101
+ this .url = url ;
102
+ }
103
+
104
+ public String getFilter () {
105
+ return filter ;
106
+ }
107
+
108
+ public void setFilter (String filter ) {
109
+ this .filter = filter ;
110
+ }
111
+
112
+ public Boolean getDeepLinking () {
113
+ return deepLinking ;
114
+ }
115
+
116
+ public void setDeepLinking (Boolean deepLinking ) {
117
+ this .deepLinking = deepLinking ;
118
+ }
119
+
120
+ public Boolean getDisplayOperationId () {
121
+ return displayOperationId ;
122
+ }
123
+
124
+ public void setDisplayOperationId (Boolean displayOperationId ) {
125
+ this .displayOperationId = displayOperationId ;
126
+ }
127
+
128
+ public Integer getDefaultModelsExpandDepth () {
129
+ return defaultModelsExpandDepth ;
130
+ }
131
+
132
+ public void setDefaultModelsExpandDepth (Integer defaultModelsExpandDepth ) {
133
+ this .defaultModelsExpandDepth = defaultModelsExpandDepth ;
134
+ }
135
+
136
+ public Integer getDefaultModelExpandDepth () {
137
+ return defaultModelExpandDepth ;
138
+ }
139
+
140
+ public void setDefaultModelExpandDepth (Integer defaultModelExpandDepth ) {
141
+ this .defaultModelExpandDepth = defaultModelExpandDepth ;
142
+ }
143
+
144
+ public String getDefaultModelRendering () {
145
+ return defaultModelRendering ;
146
+ }
147
+
148
+ public void setDefaultModelRendering (String defaultModelRendering ) {
149
+ this .defaultModelRendering = defaultModelRendering ;
150
+ }
151
+
152
+ public Boolean getDisplayRequestDuration () {
153
+ return displayRequestDuration ;
154
+ }
155
+
156
+ public void setDisplayRequestDuration (Boolean displayRequestDuration ) {
157
+ this .displayRequestDuration = displayRequestDuration ;
158
+ }
159
+
160
+ public String getDocExpansion () {
161
+ return docExpansion ;
162
+ }
163
+
164
+ public void setDocExpansion (String docExpansion ) {
165
+ this .docExpansion = docExpansion ;
166
+ }
167
+
168
+ public Integer getMaxDisplayedTags () {
169
+ return maxDisplayedTags ;
170
+ }
171
+
172
+ public void setMaxDisplayedTags (Integer maxDisplayedTags ) {
173
+ this .maxDisplayedTags = maxDisplayedTags ;
174
+ }
175
+
176
+ public Boolean getShowExtensions () {
177
+ return showExtensions ;
178
+ }
179
+
180
+ public void setShowExtensions (Boolean showExtensions ) {
181
+ this .showExtensions = showExtensions ;
182
+ }
183
+
184
+ public Boolean getShowCommonExtensions () {
185
+ return showCommonExtensions ;
186
+ }
187
+
188
+ public void setShowCommonExtensions (Boolean showCommonExtensions ) {
189
+ this .showCommonExtensions = showCommonExtensions ;
190
+ }
191
+
192
+ public String getValidatorUrl () {
193
+ return validatorUrl ;
194
+ }
195
+
196
+ public void setValidatorUrl (String validatorUrl ) {
197
+ this .validatorUrl = validatorUrl ;
198
+ }
199
+ }
0 commit comments