use of com.webcohesion.enunciate.modules.jaxrs.model.util.ReturnWrappedDocComment in project enunciate by stoicflame.
the class ResourceMethod method loadReturnType.
protected DecoratedTypeMirror loadReturnType() {
DecoratedTypeMirror returnType;
TypeHint hintInfo = getAnnotation(TypeHint.class);
if (hintInfo != null) {
returnType = (DecoratedTypeMirror) TypeHintUtils.getTypeHint(hintInfo, this.env, getReturnType());
returnType.setDeferredDocComment(new ReturnDocComment(this));
} else {
returnType = (DecoratedTypeMirror) getReturnType();
// we can use the type argument to get the entity type
if (returnType.isClass() && returnType.isInstanceOf("com.sun.jersey.api.JResponse")) {
DecoratedDeclaredType jresponse = (DecoratedDeclaredType) returnType;
if (!jresponse.getTypeArguments().isEmpty()) {
DecoratedTypeMirror responseType = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(jresponse.getTypeArguments().get(0), this.env);
if (responseType.isDeclared()) {
responseType.setDeferredDocComment(new ReturnDocComment(this));
returnType = responseType;
}
}
} else if ((returnType.isInstanceOf(javax.ws.rs.core.Response.class) || returnType.isInstanceOf(jakarta.ws.rs.core.Response.class)) || returnType.isInstanceOf(java.io.InputStream.class)) {
// generic response that doesn't have a type hint; we'll just have to assume return type of "object"
DecoratedDeclaredType objectType = (DecoratedDeclaredType) TypeMirrorDecorator.decorate(this.env.getElementUtils().getTypeElement(Object.class.getName()).asType(), this.env);
objectType.setDeferredDocComment(new ReturnDocComment(this));
returnType = objectType;
}
}
final ApiOperation apiOperation = getAnnotation(ApiOperation.class);
if (apiOperation != null) {
DecoratedTypeMirror swaggerReturnType = Annotations.mirrorOf(new Callable<Class<?>>() {
@Override
public Class<?> call() throws Exception {
return apiOperation.response();
}
}, this.env, Void.class);
if (swaggerReturnType != null) {
if (!apiOperation.responseContainer().isEmpty()) {
swaggerReturnType = (DecoratedTypeMirror) this.env.getTypeUtils().getArrayType(swaggerReturnType);
swaggerReturnType.setDeferredDocComment(new ReturnDocComment(this));
}
returnType = swaggerReturnType;
}
}
DecoratedTypeMirror returnWrapped = JAXDocletUtil.getReturnWrapped(getDocComment(), this.env, getContext().getContext().getLogger());
if (returnWrapped != null) {
returnWrapped.setDeferredDocComment(new ReturnWrappedDocComment(this));
returnType = returnWrapped;
}
return returnType;
}
Aggregations