Spring Boot 配合 swagger 使用

pom 中配置

        <!--swagger-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.5.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.5.0</version>
        </dependency>

启动类中加注解

@EnableSwagger2

Controller中配置(其中 notes 支持 markdown)

/**
 * Created by johnzh on
 * 2017/4/21. 22:08
 */
@Api(description = "商户系统")
@RestController
@RequestMapping(value = "/merchant")
public class MerchantController extends BaseController{

    private final MerchantService merchantService;

    @Autowired
    public MerchantController(MerchantService merchantService) {
        this.merchantService = merchantService;
    }

    @ApiOperation(value = "获取待办任务", httpMethod = "GET", notes = ApiNote.BACKLOG)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "页数", paramType = "query", name = "page", dataType = "int", required = true),
            @ApiImplicitParam(value = "大小", paramType = "query", name = "size", dataType = "int", required = true)
    })
    @GetMapping(value = "/backLog", produces = "application/json;charset=UTF-8")
    public String getBackLog(@Param("page") Integer page, @Param("size") Integer size, HttpSession session){
        Integer userId = getUserId(session);
        List<OrderDO> orderDOList = merchantService.getBackLog(userId, page, size);
        return responseList(orderDOList);
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 47,040评论 6 342
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,314评论 19 139
  • 此篇翻译的是Spring Boot官方指南 Part III. 使用 Spring Boot (Using Spr...
    K天道酬勤阅读 11,752评论 0 21
  • 1. Java基础部分 基础部分的顺序:基本语法,类相关的语法,内部类的语法,继承相关的语法,异常的语法,线程的语...
    子非鱼_t_阅读 31,898评论 18 399
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,194评论 4 61