码迷,mamicode.com
首页 > 编程语言 > 详细

SpringFox swagger2 and SpringFox swagger2 UI 接口文档生成与查看

时间:2018-09-01 20:25:27      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:val   api   alt   spring   一个   https   依赖   包装类   使用   

依赖:

<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.9.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.9.2</version>
</dependency>

 

使用:在你要生成接口处加上注解@EnableSwagger2  ,此处是整个项目都要,不建议这么玩, 建议加在controller上

 

@SpringBootApplication
@EnableSwagger2
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

 

方法描述: 在方法上加上 @ApiOperation

    @ApiOperation(value="这是一个上传excel的方法")
    @PostMapping("/uploadExcel")
    public CommonResponse uploadOrderExcel(@RequestParam("ePlusExcel") MultipartFile ePlusExcel,
            ) 

 效果:

技术分享图片

 

 参数描述:1. 参数是  包装类 或者模型 如PartDO   在属性上加 @ApiModelProperty(value="")

@ApiModelProperty(value="part 的 描述")
    private String partDesc;

 参数描述:2. 参数是  普通类型 如String  name   在属性上加@ApiParam(value="")

@GetMapping("/queryInventory")
        public CommonResponse queryInventory(@ApiParam(value="客户编码")String customerCode) {

效果:

技术分享图片

 

 

 

 

 查看: http://localhost:9999/swagger-ui.html

技术分享图片

 

SpringFox swagger2 and SpringFox swagger2 UI 接口文档生成与查看

标签:val   api   alt   spring   一个   https   依赖   包装类   使用   

原文地址:https://www.cnblogs.com/lshan/p/9571265.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!