title: swagger consolidation for multiple microservices
body: <p>I have multiple microservices, for which swagger has already been implemented. I would like to bring all the api's under single swagger UI. I've followed the following link for doing this. but tried it in maven approach in STS.
  <a href="https://github.com/varghgeorge/microservices-single-swagger" rel="noreferrer">Swagger Consilidation Github example</a></p>
  
  <p>Here are my different files in the project,</p>
  
  <pre><code>@SpringBootApplication
  @ComponentScan
  @EnableAutoConfiguration
  @EnableSwagger2
  public class SgtestApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(SgtestApplication.class, args);
      }
  
      @Bean
      public Docket api() {
          return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() 
                    .apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot")))
                    .apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.cloud")))
                    .apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.security")))
                       .build();
      }
  
      private ApiInfo apiInfo() {
          return new ApiInfoBuilder()
                  .title("Single swagger")
                  .description("API to retrieve swagger apis")
                  .version("1.0.0")
                  .build();
      }
  }
  </code></pre>
  
  <p>My resource provider is as follows,</p>
  
  <pre><code>@Component
  @Primary
  @EnableAutoConfiguration
  public class GatewaySwaggerResourceProvider implements SwaggerResourcesProvider {
  
      @Autowired
      private SwaggerServicesConfig swaggerServiceList;
  
      public GatewaySwaggerResourceProvider() {
      }
  
      @Override
      public List&lt;SwaggerResource&gt; get() {
          List&lt;SwaggerResource&gt; resources = new ArrayList&lt;&gt;();
  
          List&lt;SwaggerServices&gt; servList=swaggerServiceList.getServiceList();
          for (SwaggerServices swaggerServices : servList) {
              resources.add(swaggerResource(swaggerServices.getName(), swaggerServices.getUrl(),swaggerServices.getVersion()));
          }
          /*swaggerServiceList.getServiceList().forEach(service -&gt; {
              resources.add(swaggerResource(service.getName(), service.getUrl(), service.getVersion()));
          });*/
          return resources;
      }
  
      private SwaggerResource swaggerResource(String name, String location, String version) {
          SwaggerResource swaggerResource = new SwaggerResource();
          swaggerResource.setName(name);
          swaggerResource.setLocation(location);
          swaggerResource.setSwaggerVersion(version);
          return swaggerResource;
      }
  }
  </code></pre>
  
  <p>and finally my service configuration,</p>
  
  <pre><code>@Component
  @EnableAutoConfiguration
  @EnableConfigurationProperties
  @ConfigurationProperties(prefix = "documentation.swagger")
  public class SwaggerServicesConfig {
  
      List&lt;SwaggerServices&gt; swagger;
  
      public List&lt;SwaggerServices&gt; getServiceList() {
          return swagger;
      }
  
      public void setServiceList(List&lt;SwaggerServices&gt; swaggerResources) {
          this.swagger = swaggerResources;
      }
  
      @EnableConfigurationProperties
      @ConfigurationProperties(prefix = "documentation.swagger.services")
      public static class SwaggerServices {
          private String name;
          private String url;
          private String version;
  
          public String getName() {
              return name;
          }
  
          public void setName(String name) {
              this.name = name;
          }
  
          public String getUrl() {
              return url;
          }
  
          public void setUrl(String url) {
              this.url = url;
          }
  
          public String getVersion() {
              return version;
          }
  
          public void setVersion(String version) {
              this.version = version;
          }
  
          @Override
          public String toString() {
              return "SwaggerServices [name=" + name + ", url=" + url + ", version=" + version + "]";
          }
  
      }
  
  }
  </code></pre>
  
  <p>in my application.yml i am specifying the api docs endpoint of different microservices. </p>
  
  <pre><code>spring:
    profiles: default
  
  server:
    port: 8014
  
  
  documentation:
    swagger:
      service-list:
      - name: local-swagger
        url: http://localhost:8085/v2/api-docs
        version: 1.0
  </code></pre>
  
  <p>and my output is as follows,<a href="https://i.stack.imgur.com/fzOFI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fzOFI.png" alt="output"></a></p>
  
  <p>could someone help me out by what am i exactly doing wrong here? i am able to get swager ui but it is not showng any list of api's in that. I am new to swagger, so please kindly review my program.</p>