Search code examples
spring-bootswaggernetflix-eurekaspringfoxnetflix-ribbon

Swagger Springfox configuration loads before Spring Boot Config


I have several microservices and all of them are registered in Eureka (Discovery Client). Recently I have enabled Swagger2 (SpringFox) for all the microservices.

As soon as I enabled swagger my microservices started registering to Eureka as "Uknown" service and registering with default 8080 port.

My Application Class goes like this.

@SpringBootApplication
@EnableDiscoveryClient
@EnableSwagger2
public class Application {
    private static final Logger LOG = LoggerFactory.getLogger(CaseApplication.class);

    public static void main(String[] args) {
        LOG.debug("Bootstrapping Case Service");
        SpringApplication.run(Application.class, args);
    }

    @Bean
    public Docket caseApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("Audit")
                .apiInfo(apiInfo())
                .select()
                .paths(regex("/app.*"))
                .build();
    }

     @Bean
        public UiConfiguration uiConfig() {
          return new UiConfiguration("validator", UiConfiguration.Constants.NO_SUBMIT_METHODS);
        }


    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Application Service")
                .description("Application Microservice API Documentation")
                .version("1.0")
                .build();
    }
}

I have tried moving my Eureka configuration from application.yml to bootstrap.yml. But if I move my ribbon client is not able to get the application instance and the Eureka registry.

Any help will be appreciated.


Solution

  • Thanks to https://stackoverflow.com/users/19219/dilip-krishnan

    Upgrading the SpringFox release to 2.6.1-snapshot solved the problem. https://github.com/springfox/springfox/issues/1532