-public class SwaggerConfig {
- @Bean
- public Docket api() {
- return new Docket(DocumentationType.SWAGGER_2).select()
- .apis(RequestHandlerSelectors.basePackage("org.oransc.policyagent.controllers"))
- .paths(PathSelectors.any()).build();
- }
+public class SwaggerConfig extends WebMvcConfigurationSupport {
+
+ static final String API_TITLE = "A1 Policy management service";
+ static final String DESCRIPTION = "This page lists all the rest apis for the service.";
+ static final String VERSION = "1.0";
+ @SuppressWarnings("squid:S1075") // Refactor your code to get this URI from a customizable parameter.
+ static final String RESOURCES_PATH = "classpath:/META-INF/resources/";
+ static final String WEBJARS_PATH = RESOURCES_PATH + "webjars/";
+ static final String SWAGGER_UI = "swagger-ui.html";
+ static final String WEBJARS = "/webjars/**";
+
+ /**
+ * Gets the API info.
+ *
+ * @return the API info.
+ */
+ @Bean
+ public Docket api() {
+ return new Docket(DocumentationType.SWAGGER_2) //
+ .apiInfo(apiInfo()) //
+ .select() //
+ .apis(RequestHandlerSelectors.any()) //
+ .paths(PathSelectors.any()) //
+ .paths(Predicates.not(PathSelectors.regex("/error"))) //
+ // this endpoint is not implemented, but was visible for Swagger
+ .build();
+ }
+
+ private static ApiInfo apiInfo() {
+ return new ApiInfoBuilder() //
+ .title(API_TITLE) //
+ .description(DESCRIPTION) //
+ .version(VERSION) //
+ .build();
+ }
+
+ @Override
+ protected void addResourceHandlers(ResourceHandlerRegistry registry) {
+ registry.addResourceHandler(SWAGGER_UI) //
+ .addResourceLocations(RESOURCES_PATH);
+
+ registry.addResourceHandler(WEBJARS) //
+ .addResourceLocations(WEBJARS_PATH);
+ }
+