-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring: Api Objects in methods annotated with @GetMapping @PostMapping #244
Comments
Hello, I also meet this problem. After debug I found that this is caused by: @Override
public Set<Class<?>> jsondocObjects(List<String> packages) {
Set<Method> methodsAnnotatedWith = reflections.getMethodsAnnotatedWith(RequestMapping.class);
Set<Class<?>> candidates = Sets.newHashSet();
Set<Class<?>> subCandidates = Sets.newHashSet();
Set<Class<?>> elected = Sets.newHashSet();
for (Method method : methodsAnnotatedWith) {
buildJSONDocObjectsCandidates(candidates, method.getReturnType(), method.getGenericReturnType(), reflections);
Integer requestBodyParameterIndex = JSONDocUtils.getIndexOfParameterWithAnnotation(method, RequestBody.class);
if(requestBodyParameterIndex != -1) {
candidates.addAll(buildJSONDocObjectsCandidates(candidates, method.getParameterTypes()[requestBodyParameterIndex], method.getGenericParameterTypes()[requestBodyParameterIndex], reflections));
}
}
// This is to get objects' fields that are not returned nor part of the body request of a method, but that are a field
// of an object returned or a body of a request of a method
for (Class<?> clazz : candidates) {
appendSubCandidates(clazz, subCandidates, reflections);
}
candidates.addAll(subCandidates);
for (Class<?> clazz : candidates) {
if(clazz.getPackage() != null) {
for (String pkg : packages) {
if(clazz.getPackage().getName().contains(pkg)) {
elected.add(clazz);
}
}
}
}
return elected;
} |
True, meta annotations are not resolved by the getMethodsAnnotatedWith() call, so GetMapping, etc are not found. |
I observed that ApiObjects are only detected in controllers whichs methods are annotated with @RequestMapping.
They are not detected in controllers which are using @GetMapping, PostMapping ... instead.
The text was updated successfully, but these errors were encountered: