您好,登錄后才能下訂單哦!
這篇文章主要介紹了Swagger中@ApiIgnore注解怎么用,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
@ApiIgnore 可以用在類、方法上,方法參數(shù)中,用來屏蔽某些接口或參數(shù),使其不在頁面上顯示。
@ApiIgnore @Api(tags = {"Xxx控制類"}) @RestController @RequestMapping("/xxx") public class XxxController { ...... }
隱藏某個(gè)類還可以用@Api注解自帶的hidden屬性:
@Api(value = "xxx", tags = "xxx",hidden = true)
當(dāng)hidden為true時(shí),該類隱藏。
@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) { ...... }
隱藏某個(gè)方法還可以用@APIOperation注解自帶的hidden屬性:
@ApiOperation(value = "xxx", httpMethod = "GET", notes = "xxx",hidden = true)
當(dāng)hidden為true時(shí),該方法隱藏。
public String abc(@ApiIgnore String a, String b, String c){ return "a" + "b" + "c"; }
補(bǔ)充:
(1)用@ApiModelProperty注解自帶的hidden屬性:
@ApiModelProperty(value = "xxxid", required = true,hidden = true) private Long id;
(2)使用@JsonIgnore注解:
@ApiModelProperty(value = "xxxid", required = true) @JsonIgnore private Long id;
包名:
import com.fasterxml.jackson.annotation.JsonIgnore;
使用swagger時(shí)
@ApiOperation
表示生成API文檔
@Apiignore
表示忽略生成
@ApiIgnore 可以用在類、方法上,方法參數(shù)中,用來屏蔽某些接口或參數(shù),使其不在頁面上顯示。
@ApiIgnore @Api(tags = {"Xxx控制類"}) @RestController @RequestMapping("/xxx") public class XxxController { ...... }
隱藏某個(gè)類還可以用@Api注解自帶的hidden屬性:
@Api(value = "xxx", tags = "xxx",hidden = true) 當(dāng)hidden為true時(shí),該類隱藏
@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) { ...... }
隱藏某個(gè)方法還可以用@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) { ...... }
隱藏某個(gè)方法還可以用@APIOperation注解自帶的hidden屬性:
@ApiOperation(value = "xxx", httpMethod = "GET", notes = "xxx",hidden = true)
當(dāng)hidden為true時(shí),該方法隱藏
public String abc(@ApiIgnore String a, String b, String c){ return "a" + "b" + "c"; }
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“Swagger中@ApiIgnore注解怎么用”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。