springfox.boot.starter.autoconfigure.SwaggerUiWebMvcConfiguration Maven / Gradle / Ivy
package springfox.boot.starter.autoconfigure;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import static springfox.documentation.builders.BuilderDefaults.*;
@Configuration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@ConditionalOnProperty(
value = "springfox.documentation.swagger-ui.enabled",
havingValue = "true",
matchIfMissing = true)
public class SwaggerUiWebMvcConfiguration {
@Value("${springfox.documentation.swagger-ui.base-url:}")
private String swaggerBaseUrl;
@Bean
public SwaggerUiWebMvcConfigurer swaggerUiConfigurer() {
return new SwaggerUiWebMvcConfigurer(fixup(swaggerBaseUrl));
}
private String fixup(String swaggerBaseUrl) {
return StringUtils.trimTrailingCharacter(nullToEmpty(swaggerBaseUrl), '/');
}
}