2 * ============LICENSE_START======================================================================
3 * Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. All rights reserved.
4 * ===============================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END========================================================================
19 package org.onap.dcaegen2.collectors.datafile.configuration;
21 import org.springframework.context.annotation.Bean;
22 import org.springframework.context.annotation.Configuration;
23 import org.springframework.context.annotation.Profile;
24 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
25 import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
26 import springfox.documentation.builders.ApiInfoBuilder;
27 import springfox.documentation.builders.PathSelectors;
28 import springfox.documentation.builders.RequestHandlerSelectors;
29 import springfox.documentation.service.ApiInfo;
30 import springfox.documentation.spi.DocumentationType;
31 import springfox.documentation.spring.web.plugins.Docket;
32 import springfox.documentation.swagger2.annotations.EnableSwagger2;
38 public class SwaggerConfig extends WebMvcConfigurationSupport {
40 public static final String PACKAGE_PATH = "org.onap.dcaegen2.collectors.datafile";
41 public static final String API_TITLE = "DATAFILE app server";
42 public static final String DESCRIPTION = "This page lists all the rest apis for DATAFILE app server.";
43 public static final String VERSION = "1.0";
44 public static final String RESOURCES_PATH = "classpath:/META-INF/resources/";
45 public static final String WEBJARS_PATH = RESOURCES_PATH + "webjars/";
46 public static final String SWAGGER_UI = "swagger-ui.html";
47 public static final String WEBJARS = "/webjars/**";
52 * @return the API info.
56 return new Docket(DocumentationType.SWAGGER_2) //
57 .apiInfo(apiInfo()) //
58 .select().apis(RequestHandlerSelectors.basePackage(PACKAGE_PATH)) //
59 .paths(PathSelectors.any()) //
63 private ApiInfo apiInfo() {
64 return new ApiInfoBuilder() //
66 .description(DESCRIPTION) //
72 protected void addResourceHandlers(ResourceHandlerRegistry registry) {
73 registry.addResourceHandler(SWAGGER_UI) //
74 .addResourceLocations(RESOURCES_PATH);
76 registry.addResourceHandler(WEBJARS) //
77 .addResourceLocations(WEBJARS_PATH);