cod*_*ent 15 spring-mvc swagger swagger-ui
我有控制器这么简单:
@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();} );
}
Run Code Online (Sandbox Code Playgroud)
我期望只有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
Run Code Online (Sandbox Code Playgroud)
Dil*_*nan 27
您应该能够将插件设置为不使用默认响应消息.请按照以下说明了解不同版本.
对于1.0.2或之前
new SwaggerSpringMvcPlugin(...)
//More config
.useDefaultResponseMessages(false) //<-- this should be false
...;
Run Code Online (Sandbox Code Playgroud)
对于2.x.
new Docket()
//More config
.useDefaultResponseMessages(false) //<-- this should be false
...;
Run Code Online (Sandbox Code Playgroud)
小智 5
使用 OpenAPI 3,您只需将此属性添加到 applications.yml(或类似文件)
springdoc:
override-with-generic-response: false
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5875 次 |
| 最近记录: |