開發四年只會寫業務代碼,分布式高并發都不會還做程式員?->>>
如題,給swagger配置了一個全域的引數token,但是部分的介面不需要該引數(如登錄介面),如何單獨的將該介面的引數進行屏蔽(不在頁面顯示)呢?
以下為swagger基礎配置:

uj5u.com熱心網友回復:
@Bean(value = "defaultApi")
public Docket defaultApi() {
List<Parameter> pars = new ArrayList<Parameter>();
ParameterBuilder tokenPar = new ParameterBuilder();
tokenPar.name(headerToken).description(tokenDescription)
.modelRef(new ModelRef("String")).parameterType("header")
.required(tokenRequired).build(); //header中的Token引數必填,但是這里不能解區域分介面不需要token引數
pars.add(tokenPar.build());
return new Docket(DocumentationType.SWAGGER_2)
.enable(isEnable)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("project.api.auth"))
.paths(PathSelectors.any())
.build().groupName("需要token驗證").globalOperationParameters(pars).ignoredParameterTypes(HttpServletResponse.class, HttpServletRequest.class);
}
@Bean(value = "publicApi")
public Docket publicApi() {
return new Docket(DocumentationType.SWAGGER_2)
.enable(isEnable)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("project.api.pub"))
.paths(PathSelectors.any())
.build().groupName("無需token驗證").ignoredParameterTypes(HttpServletResponse.class, HttpServletRequest.class);
}
uj5u.com熱心網友回復:
已解決,使用分組功能。
uj5u.com熱心網友回復:
為什么按這種方法還是會驗證token轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/131177.html
標籤:其他技術討論專區
上一篇:鏈表節點創建
下一篇:嵌入式軟體測驗工程師的困惑
