果項目中定義了一個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;
}
