大家好,我正在尝试为Spring服务生成文档,其中有一个服务如下:
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, Object>> getAccountList(
HttpServletRequest request, HttpServletResponse response,
) {
// Get account associate with user.
List<Account> accounts =
accountDB.findAccountForUser(user.getId());
// Create response object.
Map<String, Object> responseObject = new LinkedHashMap<String, Object>();
responseObject.put(StringConstants.RESPONSE_TYPE, StringConstants.SUCCESS);
responseObject.put(StringConstants.STATUS, HttpStatus.OK.value());
responseObject.put(StringConstants.ITEMS, mapAccountList(accounts));
return new ResponseEntity<Map<String, Object>>(responseObject, HttpStatus.OK);
}
private List<Map<String, String>> mapAccountList(List<Account> accountList) {
List<Map<String, String>> accountMapList = new ArrayList<Map<String, String>>();
// Iterate over accountList and create map.
for (Account account : accountList) {
Map<String, String> accountMap = mapAccount(account);
accountMapList.add(accountMap);
}
return accountMapList;
}
这里的问题是Swagger没有生成响应信息。对于POJO情况下它能正常工作,但当我返回一个哈希表时就不行了。
有人能帮忙吗?
~谢谢。