<Object>
/<?>
/<*>
.API:
/**
* Write response using `HttpServletResponse`
*/
@RequestMapping(value = "/writeByResponse", method = RequestMethod.GET)
public void writeByResponse(HttpServletResponse response) throws IOException {
UserInfo userInfo = new UserInfo();
userInfo.setId(1l);
userInfo.setName("Tom");
userInfo.setAge(25);
response.getOutputStream().write(new Gson().toJson(Result.success(userInfo)).getBytes(Charsets.UTF_8));
}
void
, but the actual response is of type Result<UserInfo>
. Therefore, an additional approach is needed to indicate the actual response of this API
.Simple configuration:
method.return=#real_return
Usage in method:
/**
* @real_return com.itangcent.common.dto.Result<com.itangcent.common.model.UserInfo>
*/
For convenience, we can try using {@link}
to set the actual response type and use helper.resolveLink
to resolve it.
For example, configure the following:
method.return[#real_return]=groovy: helper.resolveLink(it.doc("real_return"))
Usage in method:
/**
* @real_return {@link Result<UserInfo>}
*/
Furthermore, if all responses are wrapped by com.itangcent.common.dto.Result
Configure the following:
method.return[#real_return]=groovy: "com.itangcent.common.dto.Result<" + helper.resolveLink(it.doc("real_return")) +">"
Usage in method:
/**
* @real_return {@link UserInfo}
*/