我有这样简单的 Controller :
@RequestMapping(value="/async/data", method=RequestMethod.GET, produces="application/json")
@ApiOperation(value = "Gets data", notes="Gets data asynchronously")
@ApiResponses(value={@ApiResponse(code=200, message="OK")})
public Callable<List<Data>> getData(){
return ( () -> {return dataService.loadData();} );
}
我原以为只有 HTTP 状态 200 的响应消息。但是 springfox 总是生成下面的(401、403、404)。如何禁用(不显示)它们?async-rest-controller Show/Hide List Operations Expand Operations
GET /async/data Gets data
Implementation Notes
Gets data asynchronously
Response Class (Status 200)
ModelModel Schema
{}
Response Content Type
Response Messages
HTTP Status Code Reason Response Model Headers
401 Unauthorized
403 Forbidden
404 Not Found
最佳答案
您应该能够将插件设置为 不是 使用默认响应消息。对于不同版本,请按照以下说明进行操作。
对于 1.0.2 或之前版本
new SwaggerSpringMvcPlugin(...)
//More config
.useDefaultResponseMessages(false) //<-- this should be false
...;
对于 2.x
new Docket()
//More config
.useDefaultResponseMessages(false) //<-- this should be false
...;
关于spring-mvc - Swagger - 默认情况下,Springfox 总是会生成一些响应消息 (401,403...)。我怎样才能删除它们?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30047129/