我收到以下错误:此位置不允许注释@ApiResponses我们正在使用swagger2.2.0
@RestController
@RequestMapping(value = "/example")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
@ApiResponse(code = 204, message = "No Content"),
@ApiResponse(code = 400, message = "Bad Request"),
@ApiResponse(code = 401, message = "Unauthorized"),
@ApiResponse(code = 500, message = "Internal Server Error")})
public class SomeController{
}
如果没有升级swagger版本,我们有任何选择吗?请帮忙..
这是因为@ApiResponses注释只能用于方法!
以下是一个示例代码段:
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ID supplied"),
@ApiResponse(code = 404, message = "Pet not found") })
public Response getPetById(...) {...}