更新端点的响应对象

克鲁

我使用摇摇晃晃自动生成了SpringMVC API。现在,我想手动更新一些端点。我有以下终点:

  @ApiOperation(value = "Estimation of ...", notes = "...", response = Similarity.class, responseContainer = "List")
  @io.swagger.annotations.ApiResponses(value = { 
    @io.swagger.annotations.ApiResponse(code = 200, message = "Similarity metrics", response = Similarity.class),
    @io.swagger.annotations.ApiResponse(code = 200, message = "Unexpected error", response = Similarity.class) })
  @RequestMapping(value = "/estimateSimilarity",
    produces = { "application/json" },
    method = RequestMethod.GET)
  public ResponseEntity<HashMap<String,Double>> estimateSimilarity(
          @ApiParam(value = "...", required = true)
          @RequestParam(value = "term1", required = true) String term,
          @ApiParam(value = "...", required = true)
          @RequestParam(value = "terms", required = true) List<String> concepts)
      throws NotFoundException {
      Similarity similarity = new Similarity();
      HashMap<String,Double> result = similarity.getEstimates(term1, terms);
      return new ResponseEntity<HashMap<String,Double>>(HttpStatus.OK);
  }

相反response = Similarity.class,我想返回HashMap<String,Double> result我应该如何更新上述代码才能返回此对象?

巴拉吉

尝试修改ApiOperations Response容器。

@ApiOperation(value = "Estimation of ...", notes = "...", response = Double.class, responseContainer = "Map")

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章