@@ -57,45 +57,23 @@ public abstract class AbstractSwaggerWelcome {
5757 */
5858 protected final SpringDocConfigProperties springDocConfigProperties ;
5959
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-
8060 /**
8161 * Instantiates a new Abstract swagger welcome.
8262 *
8363 * @param swaggerUiConfig the swagger ui config
8464 * @param springDocConfigProperties the spring doc config properties
85- * @param swaggerUiConfigParameters the swagger ui config parameters
8665 */
87- public AbstractSwaggerWelcome (SwaggerUiConfigProperties swaggerUiConfig , SpringDocConfigProperties springDocConfigProperties , SwaggerUiConfigParameters swaggerUiConfigParameters ) {
66+ public AbstractSwaggerWelcome (SwaggerUiConfigProperties swaggerUiConfig , SpringDocConfigProperties springDocConfigProperties ) {
8867 this .swaggerUiConfig = swaggerUiConfig ;
8968 this .springDocConfigProperties = springDocConfigProperties ;
90- this .swaggerUiConfigParameters = swaggerUiConfigParameters ;
9169 }
9270
9371 /**
9472 * Init.
9573 */
96- protected void init () {
74+ protected void init (SwaggerUiConfigParameters swaggerUiConfigParameters ) {
9775 springDocConfigProperties .getGroupConfigs ().forEach (groupConfig -> swaggerUiConfigParameters .addGroup (groupConfig .getGroup (), groupConfig .getDisplayName ()));
98- calculateUiRootPath ();
76+ calculateUiRootPath (swaggerUiConfigParameters );
9977 }
10078
10179 /**
@@ -117,30 +95,30 @@ protected String buildUrl(String contextPath, String docsUrl) {
11795 /**
11896 * Build config url.
11997 *
120- * @param uriComponentsBuilder the uri components builder
98+ * @param swaggerUiConfigParameters the swagger ui config parameters
99+ * @param uriComponentsBuilder the uri components builder
121100 */
122- protected void buildConfigUrl (UriComponentsBuilder uriComponentsBuilder ) {
101+ protected void buildConfigUrl (SwaggerUiConfigParameters swaggerUiConfigParameters , UriComponentsBuilder uriComponentsBuilder ) {
123102 if (StringUtils .isEmpty (swaggerUiConfig .getConfigUrl ())) {
124- apiDocsUrl = buildApiDocUrl ();
125- swaggerConfigUrl = buildSwaggerConfigUrl ();
126- swaggerUiConfigParameters .setConfigUrl (swaggerConfigUrl );
103+ buildApiDocUrl (swaggerUiConfigParameters );
104+ buildSwaggerConfigUrl (swaggerUiConfigParameters );
127105 if (CollectionUtils .isEmpty (swaggerUiConfigParameters .getUrls ())) {
128106 String swaggerUiUrl = swaggerUiConfig .getUrl ();
129107 if (StringUtils .isEmpty (swaggerUiUrl ))
130- swaggerUiConfigParameters .setUrl (apiDocsUrl );
108+ swaggerUiConfigParameters .setUrl (swaggerUiConfigParameters . getApiDocsUrl () );
131109 else if (swaggerUiConfigParameters .isValidUrl (swaggerUiUrl ))
132110 swaggerUiConfigParameters .setUrl (swaggerUiUrl );
133111 else
134- swaggerUiConfigParameters .setUrl (buildUrlWithContextPath (swaggerUiUrl ));
112+ swaggerUiConfigParameters .setUrl (buildUrlWithContextPath (swaggerUiConfigParameters , swaggerUiUrl ));
135113 }
136114 else
137- swaggerUiConfigParameters .addUrl (apiDocsUrl );
115+ swaggerUiConfigParameters .addUrl (swaggerUiConfigParameters . getApiDocsUrl () );
138116 if (!CollectionUtils .isEmpty (swaggerUiConfig .getUrls ())) {
139117 swaggerUiConfig .cloneUrls ()
140118 .stream ()
141119 .filter (swaggerUrl -> !swaggerUiConfigParameters .isValidUrl (swaggerUrl .getUrl ()))
142120 .forEach (swaggerUrl -> {
143- final var url = buildUrlWithContextPath (swaggerUrl .getUrl ());
121+ final var url = buildUrlWithContextPath (swaggerUiConfigParameters , swaggerUrl .getUrl ());
144122 if (!Objects .equals (url , swaggerUrl .getUrl ())) {
145123 swaggerUiConfigParameters .getUrls ()
146124 .stream ()
@@ -150,24 +128,26 @@ else if (swaggerUiConfigParameters.isValidUrl(swaggerUiUrl))
150128 });
151129 }
152130 }
153- calculateOauth2RedirectUrl (uriComponentsBuilder );
131+ calculateOauth2RedirectUrl (swaggerUiConfigParameters , uriComponentsBuilder );
154132 }
155133
156134 /**
157135 * Build swagger ui url string.
158136 *
159- * @param swaggerUiUrl the swagger ui url
137+ * @param swaggerUiConfigParameters the swagger ui config parameters
138+ * @param swaggerUiUrl the swagger ui url
160139 * @return the string
161140 */
162- protected abstract String buildUrlWithContextPath (String swaggerUiUrl );
141+ protected abstract String buildUrlWithContextPath (SwaggerUiConfigParameters swaggerUiConfigParameters , String swaggerUiUrl );
163142
164143 /**
165144 * Gets uri components builder.
166145 *
167- * @param sbUrl the sb url
146+ * @param swaggerUiConfigParameters the swagger ui config parameters
147+ * @param sbUrl the sb url
168148 * @return the uri components builder
169149 */
170- protected UriComponentsBuilder getUriComponentsBuilder (String sbUrl ) {
150+ protected UriComponentsBuilder getUriComponentsBuilder (SwaggerUiConfigParameters swaggerUiConfigParameters , String sbUrl ) {
171151 UriComponentsBuilder uriBuilder = UriComponentsBuilder .fromUriString (sbUrl );
172152 if ((swaggerUiConfig .getQueryConfigEnabled () != null && swaggerUiConfig .getQueryConfigEnabled ())) {
173153 swaggerUiConfigParameters .getConfigParameters ().entrySet ().stream ()
@@ -185,24 +165,27 @@ protected UriComponentsBuilder getUriComponentsBuilder(String sbUrl) {
185165 /**
186166 * Calculate oauth 2 redirect url.
187167 *
188- * @param uriComponentsBuilder the uri components builder
168+ * @param swaggerUiConfigParameters the swagger ui config parameters
169+ * @param uriComponentsBuilder the uri components builder
189170 */
190- protected abstract void calculateOauth2RedirectUrl (UriComponentsBuilder uriComponentsBuilder );
171+ protected abstract void calculateOauth2RedirectUrl (SwaggerUiConfigParameters swaggerUiConfigParameters , UriComponentsBuilder uriComponentsBuilder );
191172
192173 /**
193174 * Calculate ui root path.
194175 *
195- * @param sbUrls the sb urls
176+ * @param swaggerUiConfigParameters the swagger ui config parameters
177+ * @param sbUrls the sb urls
196178 */
197- protected abstract void calculateUiRootPath (StringBuilder ... sbUrls );
179+ protected abstract void calculateUiRootPath (SwaggerUiConfigParameters swaggerUiConfigParameters , StringBuilder ... sbUrls );
198180
199181 /**
200182 * Calculate ui root common.
201183 *
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
204187 */
205- protected void calculateUiRootCommon (StringBuilder sbUrl , StringBuilder [] sbUrls ) {
188+ protected void calculateUiRootCommon (SwaggerUiConfigParameters swaggerUiConfigParameters , StringBuilder sbUrl , StringBuilder [] sbUrls ) {
206189 if (ArrayUtils .isNotEmpty (sbUrls ))
207190 sbUrl = sbUrls [0 ];
208191 String swaggerPath = swaggerUiConfigParameters .getPath ();
@@ -214,16 +197,16 @@ protected void calculateUiRootCommon(StringBuilder sbUrl, StringBuilder[] sbUrls
214197 /**
215198 * Build api doc url string.
216199 *
217- * @return the string
200+ * @param swaggerUiConfigParameters the swagger ui config parameters
218201 */
219- protected abstract String buildApiDocUrl ();
202+ protected abstract void buildApiDocUrl (SwaggerUiConfigParameters swaggerUiConfigParameters );
220203
221204 /**
222205 * Build swagger config url string.
223206 *
224- * @return the string
207+ * @param swaggerUiConfigParameters the swagger ui config parameters
225208 */
226- protected abstract String buildSwaggerConfigUrl ();
209+ protected abstract void buildSwaggerConfigUrl (SwaggerUiConfigParameters swaggerUiConfigParameters );
227210
228211 /**
229212 * Gets oauth2 redirect url.
0 commit comments