相关介绍(Swagger)
-
是一款让你更好的书写API文档的规范且完整框架。
-
提供描述、生产、消费和可视化RESTful Web Service。
-
是由庞大工具集合支撑的形式化规范。这个集合涵盖了从终端用户接口、底层代码库到商业API管理的方方面面。
配置过程
源码见文章尾
pom.xml
<!--swagger-api依赖开始-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>
<!--swagger-api结束-->
配置Swagger
@Component
@EnableSwagger2
@EnableWebMvc //必须存在
//必须存在,扫描的API Controller包
@ComponentScan(basePackages = {
"com.swagger.controller"})
public class SwaggerConfig {
@Bean
public Docket customDocket(){
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo());}
private ApiInfo apiInfo(){
Contact contact = new Contact("GodF","https://www.baidu.com","1234567@qq.com")