2016-07-04 11 views
1

swaggerを使用して自動的にSpringMVC APIを生成しました。今ではいくつかのエンドポイントを手動で更新したいと思います。 私はfolloiwngエンドポイントがあります。エンドポイントの応答オブジェクトを更新する

@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を返すようにしたいです。このオブジェクトを返すために、上記のコードをどのように更新すればよいですか?

答えて

1

ApiOperations Responseコンテナを変更してみてください。

@ApiOperation(value = "Estimation of ...", notes = "...", response = Double.class, responseContainer = "Map") 
関連する問題