功能:
1 支持文档导出
另外copy到markdown文件导出为pdf
1、生成md文件:http://cv.ftqq.com/?fr=github#
2、md文件转pdf:Convert your markdown files to PDF with our online converter for free!
展开
2 支持接口测试
pom.xml
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.0</version>
</dependency>
<!-- 不满意可以注释掉换其他UI,可以同时开启多个UI -->
<!-- 官方UI,请求路径http://{host}:{port}/swagger-ui.html -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<!-- bootstrap-ui,请求路径:http://{host}:{port}/doc.html,觉得是最好的UI-->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.9.6</version>
</dependency>
java
package com.wanda.desk.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @Classname SwaggerConfig
* @Description TODO
* @Date 2021/6/8 9:16
* @Created by songlk
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi(){
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()).build();
}
private ApiInfo apiInfo(){
return new ApiInfoBuilder()
.title("Wanda desk API")
.description("万达客诉系统API")
.version("1.0")
.build();
}
}
api java
controller
package com.wanda.desk.controller;
import com.wanda.desk.util.ResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.sql.DataSource;
import java.sql.Connection;
/**
* @Classname MysqlController
* @Description TODO
* @Date 2021/6/10 19:09
* @Created by songlk
*/
@Api("api-mysql-test")
@RestController
public class MysqlController {
@Autowired
private DataSource dataSource;
// localhost:8901/api/sqlconnect
@ApiOperation(value = "获取mysql信息", notes = "mysqlinfo",
httpMethod = "GET", responseContainer = "获取成功,获取失败")
@GetMapping("/sqlconnect")
public Object getMysql(){
Connection connection=null;
try {
connection= dataSource.getConnection();
}catch (Exception e){
connection=null;
e.printStackTrace();
}
if(connection==null){
return ResponseUtil.fail(-100, "连接数据库失败");
}
return ResponseUtil.ok( "连接数据库成功");
}
}