if (!method.isAnnotationPresent(ApiOperation.class)) {
LOG.debug("Method <{}> has no ApiOperation annotation. Skipping.", method.toGenericString());
continue;
}
ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
Map<String, Object> api = Maps.newHashMap();
List<Map<String, Object>> operations = Lists.newArrayList();
String methodPath;
if (method.isAnnotationPresent(Path.class)) {
// Method has annotated Path.
methodPath = cleanRoute(method.getAnnotation(Path.class).value());
if (clazz.isAnnotationPresent(Path.class)) {
// The class has a Path, too. Prepend.
String classPath = cleanRoute(clazz.getAnnotation(Path.class).value());
methodPath = classPath + methodPath;
}
} else {
// Method has no annotated Path. We read from it's class.
if (clazz.isAnnotationPresent(Path.class)) {
methodPath = cleanRoute(clazz.getAnnotation(Path.class).value());
} else {
LOG.debug("Method <{}> has no Path annotation. Skipping.", method.toGenericString());
continue;
}
}
Produces produces = null;
if (clazz.isAnnotationPresent(Produces.class) || method.isAnnotationPresent(Produces.class)) {
produces = clazz.getAnnotation(Produces.class);
if (method.isAnnotationPresent(Produces.class)) {
produces = method.getAnnotation(Produces.class);
}
}
api.put("path", methodPath);
Map<String, Object> operation = Maps.newHashMap();
operation.put("method", determineHttpMethod(method));
operation.put("summary", apiOperation.value());
operation.put("notes", apiOperation.notes());
operation.put("nickname", method.getName());
if (produces != null) {
operation.put("produces", produces.value());
}
// skip Response.class because we can't reliably infer any schema information from its payload anyway.