Trying to configure swagger 2.10.5 with spring boot Rest API but keep getting the error Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway
Gradle
compile "io.springfox:springfox-swagger2:2.10.5"
compile "io.springfox:springfox-swagger-ui:2.10.5"
plugins {
id 'org.springframework.boot' version '2.3.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
Config File
@Configuration
@ComponentScan
@EnableSwagger2WebMvc
@ComponentScan(basePackageClasses = {
Test.class
})
public class SpringFoxConfig {
@Bean
public Docket apiDocket() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
ApplicationFile
@SpringBootApplication
public class MeroRentalRestApiApplication {
public static void main(String[] args) {
SpringApplication.run(MeroRentalRestApiApplication.class, args);
}
}
SpringFoxConfig and application are in the same package
Tried lot of the solution from the
https://github.com/springfox/springfox/issues/2191
https://github.com/springfox/springfox/issues/1996