Swagger中常用注解


使用swagger時,

@ApiOperation表示生成API文檔,

@Apiignore表示忽略生成。

 

@ApiIgnore 可以用在類、方法上,方法參數中,用來屏蔽某些接口或參數,使其不在頁面上顯示。
1、作用在類上時,整個類都會被忽略

@ApiIgnore
@Api(tags = {"Xxx控制類"})
@RestController
@RequestMapping("/xxx")
public class XxxController {
		......
}

 隱藏某個類還可以用@Api注解自帶的hidden屬性:

@Api(value = "xxx", tags = "xxx",hidden = true)

當hidden為true時,該類隱藏

 2、當作用在方法上時,方法將被忽略

@ApiIgnore
@ApiOperation(value = "xxx", httpMethod = "POST", notes = "xxx")
@ApiImplicitParams({
        @ApiImplicitParam(name = "xxx", value = "xxx", paramType = "query", dataType = "String", required = true)
})
@PostMapping("/xxx")
public Result importCarryEquExcel(String xxx) {
                ......
}

隱藏某個方法還可以用@APIOperation注解自帶的hidden屬性

@ApiIgnore
@ApiOperation(value = "xxx", httpMethod = "POST", notes = "xxx")
@ApiImplicitParams({
        @ApiImplicitParam(name = "xxx", value = "xxx", paramType = "query", dataType = "String", required = true)
})
@PostMapping("/xxx")
public Result importCarryEquExcel(String xxx) {
                ......
}

隱藏某個方法還可以用@APIOperation注解自帶的hidden屬性:

@ApiOperation(value = "xxx", httpMethod = "GET", notes = "xxx",hidden = true)

當hidden為true時,該方法隱藏

3、作用在參數上時,單個具體的參數會被忽略

public String abc(@ApiIgnore String a, String b, String c){
    return "a" + "b" + "c";
  }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM