boostrap版本swagger

功能:

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( "连接数据库成功");
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值