File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
springdoc-openapi-webflux-ui/src
main/java/org/springdoc/webflux/ui
test/java/test/org/springdoc/ui/app3 Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,8 @@ public class SwaggerWelcome extends AbstractSwaggerWelcome {
53
53
54
54
private String webJarsPrefixUrl ;
55
55
56
+ private UriComponentsBuilder oauthPrefix ;
57
+
56
58
public SwaggerWelcome (SwaggerUiConfigProperties swaggerUiConfig , SpringDocConfigProperties springDocConfigProperties ) {
57
59
super (swaggerUiConfig , springDocConfigProperties );
58
60
this .webJarsPrefixUrl = springDocConfigProperties .getWebjars ().getPrefix ();
@@ -91,8 +93,9 @@ protected void calculateUiRootPath(StringBuilder... sbUrls) {
91
93
92
94
@ Override
93
95
protected void calculateOauth2RedirectUrl (UriComponentsBuilder uriComponentsBuilder ) {
94
- if (!swaggerUiConfig .isValidUrl (swaggerUiConfig .getOauth2RedirectUrl ())) {
95
- swaggerUiConfig .setOauth2RedirectUrl (uriComponentsBuilder .path (this .uiRootPath ).path (webJarsPrefixUrl ).path (swaggerUiConfig .getOauth2RedirectUrl ()).build ().toString ());
96
+ if (oauthPrefix == null && !swaggerUiConfig .isValidUrl (swaggerUiConfig .getOauth2RedirectUrl ())) {
97
+ this .oauthPrefix = uriComponentsBuilder .path (this .uiRootPath ).path (webJarsPrefixUrl );
98
+ swaggerUiConfig .setOauth2RedirectUrl (this .oauthPrefix .path (swaggerUiConfig .getOauth2RedirectUrl ()).build ().toString ());
96
99
}
97
100
}
98
101
Original file line number Diff line number Diff line change 18
18
19
19
package test .org .springdoc .ui .app3 ;
20
20
21
+ import org .hamcrest .Matchers ;
21
22
import org .junit .jupiter .api .Test ;
22
23
import test .org .springdoc .ui .AbstractSpringDocTest ;
23
24
24
25
import org .springframework .boot .autoconfigure .SpringBootApplication ;
25
26
import org .springframework .test .context .TestPropertySource ;
27
+ import org .springframework .test .web .reactive .server .WebTestClient ;
26
28
27
29
28
30
@ TestPropertySource (properties = {
@@ -33,6 +35,11 @@ public class SpringDocApp3RedirectDefaultTest extends AbstractSpringDocTest {
33
35
34
36
@ Test
35
37
public void shouldRedirectWithDefaultQueryParams () throws Exception {
38
+ WebTestClient .ResponseSpec responseSpec = webTestClient .get ().uri ("/documentation/swagger-ui.html" ).exchange ()
39
+ .expectStatus ().isTemporaryRedirect ();
40
+ responseSpec .expectHeader ()
41
+ .value ("Location" , Matchers .is ("/documentation/webjars/swagger-ui/index.html?configUrl=/documentation/v3/api-docs/swagger-config" ));
42
+
36
43
webTestClient .get ().uri ("/documentation/v3/api-docs/swagger-config" ).exchange ()
37
44
.expectStatus ().isOk ().expectBody ()
38
45
.jsonPath ("$.validatorUrl" ).isEqualTo ("" )
You can’t perform that action at this time.
0 commit comments