|
| 1 | +package info.xiaomo.website.config; |
| 2 | + |
| 3 | +import org.springframework.context.annotation.Bean; |
| 4 | +import org.springframework.context.annotation.Configuration; |
| 5 | +import springfox.documentation.builders.ApiInfoBuilder; |
| 6 | +import springfox.documentation.builders.PathSelectors; |
| 7 | +import springfox.documentation.builders.RequestHandlerSelectors; |
| 8 | +import springfox.documentation.service.ApiInfo; |
| 9 | +import springfox.documentation.spi.DocumentationType; |
| 10 | +import springfox.documentation.spring.web.plugins.Docket; |
| 11 | +import springfox.documentation.swagger2.annotations.EnableSwagger2; |
| 12 | + |
| 13 | +/** |
| 14 | + * 把今天最好的表现当作明天最新的起点..~ |
| 15 | + * いま 最高の表現 として 明日最新の始発..~ |
| 16 | + * Today the best performance as tomorrow newest starter! |
| 17 | + * Created by IntelliJ IDEA. |
| 18 | + * |
| 19 | + * @author: xiaomo |
| 20 | + * @github: https://github.com/qq83387856 |
| 21 | + * @email: hupengbest@163.com |
| 22 | + * @QQ_NO: 83387856 |
| 23 | + * @Date: 2016/11/10 10:42 |
| 24 | + * @Description: 用户实体类 |
| 25 | + * @Copyright(©) 2015 by xiaomo. |
| 26 | + **/ |
| 27 | + |
| 28 | +@Configuration |
| 29 | +@EnableSwagger2 |
| 30 | +public class Swagger2Config { |
| 31 | + |
| 32 | + @Bean |
| 33 | + public Docket createRestApi() { |
| 34 | + return new Docket(DocumentationType.SWAGGER_2) |
| 35 | + .apiInfo(apiInfo()) |
| 36 | + .select() |
| 37 | + .apis(RequestHandlerSelectors.basePackage("info.xiaomo.website")) |
| 38 | + .paths(PathSelectors.any()) |
| 39 | + .build(); |
| 40 | + } |
| 41 | + |
| 42 | + private ApiInfo apiInfo() { |
| 43 | + return new ApiInfoBuilder() |
| 44 | + .title("Spring Boot中使用Swagger2构建RESTful APIs") |
| 45 | + .description("api根地址:http://api.xiaomo.info:8080/") |
| 46 | + .termsOfServiceUrl("http://blog.xiaomo.info/") |
| 47 | + .contact("小莫") |
| 48 | + .version("1.0") |
| 49 | + .build(); |
| 50 | + } |
| 51 | +} |
0 commit comments