@@ -57,45 +57,23 @@ public abstract class AbstractSwaggerWelcome {
57
57
*/
58
58
protected final SpringDocConfigProperties springDocConfigProperties ;
59
59
60
- /**
61
- * The Swagger ui calculated config.
62
- */
63
- protected final SwaggerUiConfigParameters swaggerUiConfigParameters ;
64
-
65
- /**
66
- * The Swagger config url.
67
- */
68
- protected String swaggerConfigUrl ;
69
-
70
- /**
71
- * The Api docs url.
72
- */
73
- protected String apiDocsUrl ;
74
-
75
- /**
76
- * The Context path.
77
- */
78
- protected String contextPath ;
79
-
80
60
/**
81
61
* Instantiates a new Abstract swagger welcome.
82
62
*
83
63
* @param swaggerUiConfig the swagger ui config
84
64
* @param springDocConfigProperties the spring doc config properties
85
- * @param swaggerUiConfigParameters the swagger ui config parameters
86
65
*/
87
- public AbstractSwaggerWelcome (SwaggerUiConfigProperties swaggerUiConfig , SpringDocConfigProperties springDocConfigProperties , SwaggerUiConfigParameters swaggerUiConfigParameters ) {
66
+ public AbstractSwaggerWelcome (SwaggerUiConfigProperties swaggerUiConfig , SpringDocConfigProperties springDocConfigProperties ) {
88
67
this .swaggerUiConfig = swaggerUiConfig ;
89
68
this .springDocConfigProperties = springDocConfigProperties ;
90
- this .swaggerUiConfigParameters = swaggerUiConfigParameters ;
91
69
}
92
70
93
71
/**
94
72
* Init.
95
73
*/
96
- protected void init () {
74
+ protected void init (SwaggerUiConfigParameters swaggerUiConfigParameters ) {
97
75
springDocConfigProperties .getGroupConfigs ().forEach (groupConfig -> swaggerUiConfigParameters .addGroup (groupConfig .getGroup (), groupConfig .getDisplayName ()));
98
- calculateUiRootPath ();
76
+ calculateUiRootPath (swaggerUiConfigParameters );
99
77
}
100
78
101
79
/**
@@ -117,30 +95,30 @@ protected String buildUrl(String contextPath, String docsUrl) {
117
95
/**
118
96
* Build config url.
119
97
*
120
- * @param uriComponentsBuilder the uri components builder
98
+ * @param swaggerUiConfigParameters the swagger ui config parameters
99
+ * @param uriComponentsBuilder the uri components builder
121
100
*/
122
- protected void buildConfigUrl (UriComponentsBuilder uriComponentsBuilder ) {
101
+ protected void buildConfigUrl (SwaggerUiConfigParameters swaggerUiConfigParameters , UriComponentsBuilder uriComponentsBuilder ) {
123
102
if (StringUtils .isEmpty (swaggerUiConfig .getConfigUrl ())) {
124
- apiDocsUrl = buildApiDocUrl ();
125
- swaggerConfigUrl = buildSwaggerConfigUrl ();
126
- swaggerUiConfigParameters .setConfigUrl (swaggerConfigUrl );
103
+ buildApiDocUrl (swaggerUiConfigParameters );
104
+ buildSwaggerConfigUrl (swaggerUiConfigParameters );
127
105
if (CollectionUtils .isEmpty (swaggerUiConfigParameters .getUrls ())) {
128
106
String swaggerUiUrl = swaggerUiConfig .getUrl ();
129
107
if (StringUtils .isEmpty (swaggerUiUrl ))
130
- swaggerUiConfigParameters .setUrl (apiDocsUrl );
108
+ swaggerUiConfigParameters .setUrl (swaggerUiConfigParameters . getApiDocsUrl () );
131
109
else if (swaggerUiConfigParameters .isValidUrl (swaggerUiUrl ))
132
110
swaggerUiConfigParameters .setUrl (swaggerUiUrl );
133
111
else
134
- swaggerUiConfigParameters .setUrl (buildUrlWithContextPath (swaggerUiUrl ));
112
+ swaggerUiConfigParameters .setUrl (buildUrlWithContextPath (swaggerUiConfigParameters , swaggerUiUrl ));
135
113
}
136
114
else
137
- swaggerUiConfigParameters .addUrl (apiDocsUrl );
115
+ swaggerUiConfigParameters .addUrl (swaggerUiConfigParameters . getApiDocsUrl () );
138
116
if (!CollectionUtils .isEmpty (swaggerUiConfig .getUrls ())) {
139
117
swaggerUiConfig .cloneUrls ()
140
118
.stream ()
141
119
.filter (swaggerUrl -> !swaggerUiConfigParameters .isValidUrl (swaggerUrl .getUrl ()))
142
120
.forEach (swaggerUrl -> {
143
- final var url = buildUrlWithContextPath (swaggerUrl .getUrl ());
121
+ final var url = buildUrlWithContextPath (swaggerUiConfigParameters , swaggerUrl .getUrl ());
144
122
if (!Objects .equals (url , swaggerUrl .getUrl ())) {
145
123
swaggerUiConfigParameters .getUrls ()
146
124
.stream ()
@@ -150,24 +128,26 @@ else if (swaggerUiConfigParameters.isValidUrl(swaggerUiUrl))
150
128
});
151
129
}
152
130
}
153
- calculateOauth2RedirectUrl (uriComponentsBuilder );
131
+ calculateOauth2RedirectUrl (swaggerUiConfigParameters , uriComponentsBuilder );
154
132
}
155
133
156
134
/**
157
135
* Build swagger ui url string.
158
136
*
159
- * @param swaggerUiUrl the swagger ui url
137
+ * @param swaggerUiConfigParameters the swagger ui config parameters
138
+ * @param swaggerUiUrl the swagger ui url
160
139
* @return the string
161
140
*/
162
- protected abstract String buildUrlWithContextPath (String swaggerUiUrl );
141
+ protected abstract String buildUrlWithContextPath (SwaggerUiConfigParameters swaggerUiConfigParameters , String swaggerUiUrl );
163
142
164
143
/**
165
144
* Gets uri components builder.
166
145
*
167
- * @param sbUrl the sb url
146
+ * @param swaggerUiConfigParameters the swagger ui config parameters
147
+ * @param sbUrl the sb url
168
148
* @return the uri components builder
169
149
*/
170
- protected UriComponentsBuilder getUriComponentsBuilder (String sbUrl ) {
150
+ protected UriComponentsBuilder getUriComponentsBuilder (SwaggerUiConfigParameters swaggerUiConfigParameters , String sbUrl ) {
171
151
UriComponentsBuilder uriBuilder = UriComponentsBuilder .fromUriString (sbUrl );
172
152
if ((swaggerUiConfig .getQueryConfigEnabled () != null && swaggerUiConfig .getQueryConfigEnabled ())) {
173
153
swaggerUiConfigParameters .getConfigParameters ().entrySet ().stream ()
@@ -185,24 +165,27 @@ protected UriComponentsBuilder getUriComponentsBuilder(String sbUrl) {
185
165
/**
186
166
* Calculate oauth 2 redirect url.
187
167
*
188
- * @param uriComponentsBuilder the uri components builder
168
+ * @param swaggerUiConfigParameters the swagger ui config parameters
169
+ * @param uriComponentsBuilder the uri components builder
189
170
*/
190
- protected abstract void calculateOauth2RedirectUrl (UriComponentsBuilder uriComponentsBuilder );
171
+ protected abstract void calculateOauth2RedirectUrl (SwaggerUiConfigParameters swaggerUiConfigParameters , UriComponentsBuilder uriComponentsBuilder );
191
172
192
173
/**
193
174
* Calculate ui root path.
194
175
*
195
- * @param sbUrls the sb urls
176
+ * @param swaggerUiConfigParameters the swagger ui config parameters
177
+ * @param sbUrls the sb urls
196
178
*/
197
- protected abstract void calculateUiRootPath (StringBuilder ... sbUrls );
179
+ protected abstract void calculateUiRootPath (SwaggerUiConfigParameters swaggerUiConfigParameters , StringBuilder ... sbUrls );
198
180
199
181
/**
200
182
* Calculate ui root common.
201
183
*
202
- * @param sbUrl the sb url
203
- * @param sbUrls the sb urls
184
+ * @param swaggerUiConfigParameters the swagger ui config parameters
185
+ * @param sbUrl the sb url
186
+ * @param sbUrls the sb urls
204
187
*/
205
- protected void calculateUiRootCommon (StringBuilder sbUrl , StringBuilder [] sbUrls ) {
188
+ protected void calculateUiRootCommon (SwaggerUiConfigParameters swaggerUiConfigParameters , StringBuilder sbUrl , StringBuilder [] sbUrls ) {
206
189
if (ArrayUtils .isNotEmpty (sbUrls ))
207
190
sbUrl = sbUrls [0 ];
208
191
String swaggerPath = swaggerUiConfigParameters .getPath ();
@@ -214,16 +197,16 @@ protected void calculateUiRootCommon(StringBuilder sbUrl, StringBuilder[] sbUrls
214
197
/**
215
198
* Build api doc url string.
216
199
*
217
- * @return the string
200
+ * @param swaggerUiConfigParameters the swagger ui config parameters
218
201
*/
219
- protected abstract String buildApiDocUrl ();
202
+ protected abstract void buildApiDocUrl (SwaggerUiConfigParameters swaggerUiConfigParameters );
220
203
221
204
/**
222
205
* Build swagger config url string.
223
206
*
224
- * @return the string
207
+ * @param swaggerUiConfigParameters the swagger ui config parameters
225
208
*/
226
- protected abstract String buildSwaggerConfigUrl ();
209
+ protected abstract void buildSwaggerConfigUrl (SwaggerUiConfigParameters swaggerUiConfigParameters );
227
210
228
211
/**
229
212
* Gets oauth2 redirect url.
0 commit comments