How would I enable swagger ui in jhipster generator for microservice application? I notice it only supports swagger for gateway, so how do I configure swagger ui so that it works on microservice application as well?
Configuration Progress
Added springfox-swagger2 and springfox-swagger-ui dependencies to pom.xml
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
Created this class and added to spring directory
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.any())
.paths(paths())
.build();
}
// Describe your apis
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Swagger Sample APIs")
.description("This page lists all the rest apis for Swagger Sample App.")
.version("1.0-SNAPSHOT")
.build();
}
// Only select apis that matches the given Predicates.
private Predicate<String> paths() {
// Match all paths except /error
return Predicates.and(
PathSelectors.regex("/.*"),
Predicates.not(PathSelectors.regex("/error.*"))
);
}
}
}