我正在尝试在scala项目中使用swagger-codegen生成的接口。这是为我的方法生成的代码:
@ApiOperation(value = "", nickname = "submitJob", notes = "Execute a job", response = GetJob.class, tags={ "jobs", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Get job info", response = GetJob.class) })
@RequestMapping(value = "/api/v1/jobs/{requestId}",
produces = { "application/json" },
method = RequestMethod.PUT)
default ResponseEntity<GetJob> submitJob(@ApiParam(value = "",required=true) @PathVariable("requestId") UUID requestId,@ApiParam(value = "Job to be submitted" ,required=true ) @Valid @RequestBody JobRequest body) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
try {
return new ResponseEntity<>(getObjectMapper().get().readValue("\"\"", GetJob.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type application/json", e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
} else {
log.warn("ObjectMapper or HttpServletRequest not configured in default ApiApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
我试图用这个覆盖它:
@ApiOperation(value = "", nickname = "submitJob", notes = "Execute a
job", response = classOf[GetJob], tags = Array("jobs"))
@ApiResponses(value = Array(new ApiResponse(code = 200, message =
"Get job info", response = classOf[GetJob])))
@RequestMapping(value = Array("/api/v1/jobs/{requestId}"), produces =
Array("application/json"), method = Array(RequestMethod.PUT))
override def submitJob(@ApiParam(value = "", required = true)
@PathVariable("requestId") requestId: UUID, @ApiParam(value = "Job to
be submitted", required = true) @Valid @RequestBody body: JobRequest):
ResponseEntity[GetJob] = {
// my method here
}
如果我不使用覆盖,我会得到一个“已在范围内定义的方法”错误。如果我使用覆盖,我会得到“方法无法覆盖”。
是什么给出了?