-
-
Notifications
You must be signed in to change notification settings - Fork 540
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Hi,
when using authorization via Oauth2 the redirect URL is set to /oauth2-redirect.html
so it misses contextpath and the path to /swagger-ui
.
I've fixed it by overriding the SwaggerUiConfigProperties
and add oauth2RedirectUrl
to the configParameters
property.
My Workaround
ExtenedSwaggerUiConfigProperties.java
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.springdoc.core.SwaggerUiConfigProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import java.util.Map;
@Configuration
@Primary
@Getter
@Setter
public class ExtenedSwaggerUiConfigProperties extends SwaggerUiConfigProperties {
private String oauth2RedirectUrl;
public Map<String, String> getConfigParameters() {
Map<String, String> params = super.getConfigParameters();
if (StringUtils.isNotEmpty(oauth2RedirectUrl)) {
put("oauth2RedirectUrl"
, ServletUriComponentsBuilder.fromCurrentContextPath().path(oauth2RedirectUrl).build().toString()
, params);
}
return params;
}
}
application.properties
springdoc.swagger-ui.oauth2RedirectUrl=/swagger-ui/oauth2-redirect.html
Maybe it's possible to add the support for this property by default.
Mario-Eis
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request