Skip to content

Commit c883b02

Browse files
committed
Merge branch 'native-oauth' of https://github.com/mwiede/springdoc-openapi into mwiede-native-oauth
2 parents 830f826 + 0cbbd97 commit c883b02

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/Constants.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ public final class Constants {
183183
*/
184184
public static final String INDEX_PAGE = "/index.html";
185185

186+
/**
187+
* the constant OAUTH_REDIRECT_PAGE.
188+
*/
189+
public static final String OAUTH_REDIRECT_PAGE = "/oauth2-redirect.html";
190+
186191
/**
187192
* The constant SWAGGER_UI_URL.
188193
*/
@@ -201,7 +206,7 @@ public final class Constants {
201206
/**
202207
* The constant SWAGGER_UI_OAUTH_REDIRECT_URL.
203208
*/
204-
public static final String SWAGGER_UI_OAUTH_REDIRECT_URL = SWAGGER_UI_PREFIX + "/oauth2-redirect.html";
209+
public static final String SWAGGER_UI_OAUTH_REDIRECT_URL = SWAGGER_UI_PREFIX + OAUTH_REDIRECT_PAGE;
205210

206211
/**
207212
* The constant APPLICATION_OPENAPI_YAML.

springdoc-openapi-common/src/main/java/org/springdoc/ui/AbstractSwaggerWelcome.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.springframework.web.util.UriComponentsBuilder;
3333

3434
import static org.springdoc.core.Constants.INDEX_PAGE;
35+
import static org.springdoc.core.Constants.OAUTH_REDIRECT_PAGE;
3536
import static org.springdoc.core.Constants.SWAGGER_UI_OAUTH_REDIRECT_URL;
3637
import static org.springdoc.core.Constants.SWAGGER_UI_PREFIX;
3738
import static org.springdoc.core.Constants.SWAGGER_UI_URL;
@@ -221,7 +222,12 @@ protected void calculateUiRootCommon(StringBuilder sbUrl, StringBuilder[] sbUrls
221222
* @return the oauth2 redirect url
222223
*/
223224
protected String getOauth2RedirectUrl() {
224-
return StringUtils.defaultIfBlank(swaggerUiConfig.getOauth2RedirectUrl(), SWAGGER_UI_OAUTH_REDIRECT_URL);
225+
if (StringUtils.isNotEmpty(swaggerUiConfig.getVersion())) {
226+
return StringUtils.defaultIfBlank(swaggerUiConfig.getOauth2RedirectUrl(), SWAGGER_UI_PREFIX + DEFAULT_PATH_SEPARATOR + swaggerUiConfig.getVersion() + OAUTH_REDIRECT_PAGE);
227+
}
228+
else {
229+
return StringUtils.defaultIfBlank(swaggerUiConfig.getOauth2RedirectUrl(), SWAGGER_UI_OAUTH_REDIRECT_URL);
230+
}
225231
}
226232

227233
/**

0 commit comments

Comments
 (0)