| /* |
| ******************************************************************************* |
| * Copyright (c) 2019 Contributors to the Eclipse Foundation |
| * |
| * See the NOTICE file(s) distributed with this work for additional |
| * information regarding copyright ownership. |
| * |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0. |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| ******************************************************************************* |
| */ |
| package org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.config; |
| |
| import lombok.extern.log4j.Log4j2; |
| import org.springframework.beans.factory.annotation.Value; |
| import org.springframework.context.annotation.Bean; |
| import org.springframework.context.annotation.Configuration; |
| import org.springframework.context.annotation.Profile; |
| import springfox.documentation.spi.DocumentationType; |
| import springfox.documentation.spring.web.paths.RelativePathProvider; |
| import springfox.documentation.spring.web.plugins.Docket; |
| import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| |
| import javax.servlet.ServletContext; |
| |
| @Log4j2 |
| @Configuration |
| @EnableSwagger2 |
| @Profile({"!test","!prod"}) |
| public class SwaggerConfig { |
| |
| @Value("${swagger.baseUrl:}") |
| public String baseUrl; |
| @Value("${swagger.proxyUrl:}") |
| public String proxyUrl; |
| |
| @Bean |
| public Docket api(ServletContext servletContext) { |
| return new Docket(DocumentationType.SWAGGER_2).pathProvider(new RelativePathProvider(servletContext) { |
| @Override |
| public String getApplicationBasePath() { |
| return baseUrl + super.getApplicationBasePath(); |
| } |
| }).host(proxyUrl); |
| } |
| } |