<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
// Web Security Config
public static final String[] excludedURLs = {
"/swagger-ui.html", "/webjars/**", "/swagger-resources/**", "/v2/**"};
@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return (web) -> web.ignoring().antMatchers(excludedURLs);
}
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authenticationProvider(XXXXAPIAuthenticationProvider)
.httpBasic()
.and()
.authorizeRequests()
.antMatchers(excludedURLs).permitAll()
.anyRequest().authenticated()
.and()
.addFilter(getXXXXXBasicAuthenticationFilter())
.addFilterBefore(getOktaAuthFilter(), XXXXXXBasicAuthenticationFilter.class)
.csrf().disable();
return http.build();
}
// Swagger Config
@Profile({"Test","STAGE"})
@Configuration
@EnableSwagger2
public class SwaggerConfig {
private static final String AUTHORIZATION_HEADER = "Authorization";
public static final String DEFAULT_INCLUDE_PATTERN = "/.*";
@Bean
public Docket api() {
Docket docket=new Docket(DocumentationType.SWAGGER_2)
.securityContexts(Lists.newArrayList(securityContext()))
.securitySchemes(Lists.newArrayList(apiKey()))
.useDefaultResponseMessages(false)
.select()
.apis(RequestHandlerSelectors
.basePackage("com.XXXX.XXXX.controllers"))
.paths(regex("/.*"))
.build()
.apiInfo(apiEndPointsInfo());
docket = docket.select()
.paths(regex(DEFAULT_INCLUDE_PATTERN))
.build();
return docket;
}
I have gone through below posts
Why does springfox-swagger2 UI tell me "Unable to infer base url."
https://github.com/springfox/springfox/issues/2191
https://github.com/springfox/springfox/issues/2907
Unable to infer base url... springfox-swagger2 version 2.9.2
Please let me know what am I missing