| | |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.core.env.Environment; |
| | | import springfox.documentation.builders.ApiInfoBuilder; |
| | | import springfox.documentation.builders.PathSelectors; |
| | | import springfox.documentation.builders.RequestHandlerSelectors; |
| | |
| | | import springfox.documentation.spring.web.plugins.Docket; |
| | | import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | @Configuration |
| | | @EnableSwagger2 |
| | | public class SwaggerConfig { |
| | | @Resource |
| | | Environment env; |
| | | |
| | | private List<ApiKey> securitySchemes() { |
| | | List<ApiKey> apiKeys = new ArrayList<ApiKey>(); |
| | | apiKeys.add(new ApiKey("Authorization", "token", "header")); |
| | |
| | | |
| | | @Bean |
| | | public Docket createRestApi() { |
| | | String swaggerEnable = env.getProperty("sys.swaggerEnable"); |
| | | boolean enable = "true".equals(swaggerEnable); |
| | | |
| | | return new Docket(DocumentationType.SWAGGER_2) |
| | | .apiInfo(apiInfo()).select() |
| | | .enable(enable) |
| | | .apiInfo(apiInfo()) |
| | | .select() |
| | | .apis(RequestHandlerSelectors.basePackage("com.terra.system.controller")) |
| | | //.securitySchemes(securitySchemes()) |
| | | //.securityContexts(securityContexts()) |