我想用 @ApiResponse 注释定义操作的“默认”响应。我正在使用 swagger annotations 1.5.x 并希望生成这样的东西(查看默认响应):
"get" : {
...
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Address"
}
}
},
"default" : {
"description" : "unsuccessful operation",
"schema" : {
"$ref" : "#/definitions/ErrorResponse"
}
}
},
...
}
Run Code Online (Sandbox Code Playgroud)
但我不知道该怎么做,因为 @ApiResponse(code = ...) 注释只需要数字而不是字符串。
我的Java代码:
...
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Address.class, responseContainer = "List"),
@ApiResponse(code = "default", message = "unsuccessful operation", response = ErrorMessage.class),
...})
public Response getAllAddresses() throws SQLException {
...
}
Run Code Online (Sandbox Code Playgroud)
那么有没有办法在 Swagger 注释 1.5.x 中指定“默认”ApiResponse?
| 归档时间: |
|
| 查看次数: |
915 次 |
| 最近记录: |