boostrap版本swagger

news/2024/7/21 15:14:12 标签: java, vim

功能:

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


http://www.niftyadmin.cn/n/1334176.html

相关文章

Python实用模块(二十四)tenacity

软硬件环境windows 10 64bitsanaconda with python 3.7tenacity简介在实际应用中&#xff0c;经常会碰到在web请求时&#xff0c;因为网络的不稳定&#xff0c;会有请求超时的问题&#xff0c;这时候&#xff0c;一般都是自己去实现重试请求的逻辑&#xff0c;直到得到响应或者…

3D人体和手势运动估计

软硬件环境ubuntu 18.04 64bitNVidia GTX 1070Ticuda 10.1cudnn 7.6.35pytorch 1.6anaconda with python 3.7前言前文介绍过的 OpenPose人体姿态估计 https://xugaoxiang.com/2020/10/26/openpose-build/ 实现的是2D姿态估计&#xff0c;本文给大家介绍的是3D的人体姿态估计&a…

再见MybatisPlus,阿里推出新ORM框架

使用fluent mybatis也可以不用写具体的 xml 文件&#xff0c;通过 java api 可以构造出比较复杂的业务 sql 语句&#xff0c;做到代码逻辑和 sql 逻辑的合一。不再需要在 Dao 中组装查询或更新操作&#xff0c;或在 xml 与 mapper 中再组装参数。那对比原生 Mybatis&#xff0c…

Python实用模块(二十五)loguru

软硬件环境windows 10 64bitsanaconda with python 3.7loguru 0.5.3前言Python实用模块(十四)logging https://xugaoxiang.com/2019/12/04/python-module-logging 已 经介绍过了python内置日志模块logging。我们要使用logging&#xff0c;一般来讲&#xff0c;都是需要进行一些…

挂载nas

sudo mount -t nfs -o soft,timeo50,retrans5,retry1,intr,vers3 isilon-cluster01-prod.wanda.cn:/ifs/data/nfs/xzgpt /home/appuser/file/storageFile

pip使用指南

软硬件环境windows 10 64bitsanaconda with python 3.7前言python语言之所以如此受欢迎&#xff0c;能够在众多高级编程语言中脱颖而出&#xff0c;除了简单的语法&#xff0c;更低的学习成本外&#xff0c;更重要的是其完美的生态&#xff0c;我们有数以万计的第三方库可以使用…

使用postman传递数组调试

以springboot两个接收参数的注解为例&#xff1a;RequestBody和RequestParam 一、先简单的写一下springboot的注解RequestBody和RequestParam在后台是如何接收数组 直接上图&#xff08;自行忽略其他注解&#xff09; RequestBody接收数组RequestParam接收数组 请注意Request…

Python实用模块(二十六)argparse

软硬件环境windows 10 64bitsanaconda with python 3.7argparse前言argparse模块是python自带的命令行参数解析包&#xff0c;可以用来方便地读取命令行参数。当你的代码需要频繁地修改参数的时候&#xff0c;使用argparse可以将参数和代码分离开来&#xff0c;让你的代码更简洁…