【发布时间】:2015-06-17 08:00:33
【问题描述】:
各位,我正在尝试为 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 的情况下,它可以正常工作,但是当我返回哈希图时,它就不行了。
有人可以帮忙吗?
~谢谢。
【问题讨论】:
标签: java documentation swagger