昂扬的注解描述了操作的默认响应

时间:2018-10-08 08:33:11

标签: java swagger

我想使用@ApiResponse批注定义操作的“默认”响应。 我正在使用摇摇欲坠的注释1.5.x,并希望生成类似这样的内容(查看默认响应):

"get" : {
    ...
    "responses" : {
      "200" : {
        "description" : "successful operation",
        "schema" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Address"
          }
        }
      },
      "default" : {
        "description" : "unsuccessful operation",
        "schema" : {
          "$ref" : "#/definitions/ErrorResponse"
        }
      }
    },
    ...
  }

但是我不知道该怎么做,因为@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 {
...
}

那么有什么方法可以在Swagger注释1.5.x中指定“默认” ApiResponse吗?

0 个答案:

没有答案