@author Exrickx
| 18 | * @author Exrickx |
| 19 | */ |
| 20 | @Configuration |
| 21 | @EnableSwagger2 |
| 22 | public class Swagger2Config { |
| 23 | |
| 24 | private Logger log = LoggerFactory.getLogger(Swagger2Config.class); |
| 25 | |
| 26 | @Bean |
| 27 | public Docket createRestApi() { |
| 28 | |
| 29 | log.info("开始加载Swagger2..."); |
| 30 | |
| 31 | return new Docket(DocumentationType.SWAGGER_2) |
| 32 | .apiInfo(apiInfo()).select() |
| 33 | //扫描所有有注解的api,用这种方式更灵活 |
| 34 | .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) |
| 35 | .paths(PathSelectors.any()) |
| 36 | .build(); |
| 37 | } |
| 38 | |
| 39 | private ApiInfo apiInfo() { |
| 40 | return new ApiInfoBuilder() |
| 41 | .title("XPay Api Documentation") |
| 42 | .description("XPay个人支付收款系统API接口文档") |
| 43 | .termsOfServiceUrl("http://xpay.exrick.cn/") |
| 44 | .contact(new Contact("Exrick", "http://blog.exrick.cn", "1012139570@qq.com")) |
| 45 | .version("1.0.0") |
| 46 | .build(); |
| 47 | } |
| 48 | } |
nothing calls this directly
no outgoing calls
no test coverage detected