Swagger2 @ApiIgnore注解忽略接口在swagger-ui.html中显示

果项目中定义了一个controller,但是我们又不想把这个接口在swagger-ui.html中体现出来怎么办?不要着急,Swagger2已经替我们想到了这个问题,只要把@ApiIgnore放到你想放到的方法上就可以了,如下:

//忽略接口,不让其在Swagger文档中显示
    @ApiIgnore
    @RequestMapping("/unauth")
    public ResponseResult unauth() {
        log.info("未登录");
        ResponseResult result = new ResponseResult();
        result.setCode(Result.NOTLOGIN.getCode());
        result.setMsg(Result.NOTLOGIN.getMsg());
        return result;
    }