@Override public Optional<String> apply(Api input) { if (null != input) { return Optional.fromNullable(emptyToNull(input.description())); } return Optional.absent(); } };
@Override public Optional<String> apply(Api input) { if (null != input) { return Optional.fromNullable(emptyToNull(input.description())); } return Optional.absent(); } };
private String getDescription(HandlerMethod handlerMethod) { Class<?> controllerClass = handlerMethod.getBeanType(); String description = splitCamelCase(controllerClass.getSimpleName(), " "); Api apiAnnotation = AnnotationUtils.findAnnotation(controllerClass, Api.class); if (null != apiAnnotation) { String descriptionFromAnnotation = Optional.fromNullable(emptyToNull(apiAnnotation.value())) .or(apiAnnotation.description()); if (!isNullOrEmpty(descriptionFromAnnotation)) { return descriptionFromAnnotation; } } return description; } }
apiDescription.put("name", info.value()); apiDescription.put("path", path.value()); apiDescription.put("description", info.description());
String shortDescription = api.value(); setOptionalAttribute(classElement, "shortDesc", shortDescription); String longDescription = api.description(); setOptionalAttribute(classElement, "description", longDescription); String basePathAttr = api.basePath();
/** * Adds data from the {@link Api} annotation to the resource. * * @param api * The {@link Api} annotation. * @param resource * The {@link Resource} to update. */ public static void processApi(Api api, Resource resource) { if (!StringUtils.isNullOrEmpty(api.value())) { resource.setName(api.value()); } if (!StringUtils.isNullOrEmpty(api.description())) { resource.setDescription(api.description()); } }
/** * Adds data from the {@link Api} annotation to the resource. * * @param api * The {@link Api} annotation. * @param resource * The {@link Resource} to update. */ public static void processApi(Api api, Resource resource) { if (!StringUtils.isNullOrEmpty(api.value())) { resource.setName(api.value()); } if (!StringUtils.isNullOrEmpty(api.description())) { resource.setDescription(api.description()); } }
/** * Adds data from the {@link Api} annotation to the resource. * * @param api * The {@link Api} annotation. * @param resource * The {@link Resource} to update. */ public static void processApi(Api api, Resource resource) { if (!StringUtils.isNullOrEmpty(api.value())) { resource.setName(api.value()); } if (!StringUtils.isNullOrEmpty(api.description())) { resource.setDescription(api.description()); } }
/** * Adds data from the {@link Api} annotation to the resource. * * @param api * The {@link Api} annotation. * @param resource * The {@link Resource} to update. */ public static void processApi(Api api, Resource resource) { if (!StringUtils.isNullOrEmpty(api.value())) { resource.setName(api.value()); } if (!StringUtils.isNullOrEmpty(api.description())) { resource.setDescription(api.description()); } }
/** * Adds data from the {@link Api} annotation to the resource. * * @param api * The {@link Api} annotation. * @param resource * The {@link Resource} to update. */ public static void processApi(Api api, Resource resource) { if (!StringUtils.isNullOrEmpty(api.value())) { resource.setName(api.value()); } if (!StringUtils.isNullOrEmpty(api.description())) { resource.setDescription(api.description()); } }
private Map<String, ApiListing> processControllers(Set<Class<?>> controllerClasses) { //Loop over end points (controllers) for (Class<?> controllerClass : controllerClasses) { if (ApiDocumentationController.class.isAssignableFrom(controllerClass)) { continue; } Set<Method> requestMappingMethods = AnnotationUtils.getAnnotatedMethods(controllerClass, RequestMapping.class); ApiListing apiListing = processControllerApi(controllerClass); String description = ""; Api controllerApi = controllerClass.getAnnotation(Api.class); if (controllerApi != null) { description = controllerApi.description(); } if (apiListing.apis().size() == 0) { apiListing = processMethods(requestMappingMethods, controllerClass, apiListing, description); } //Allow for multiple controllers having the same resource path. ApiListing existingApiListing = apiListingMap.get(apiListing.resourcePath()); if (existingApiListing != null) { apiListing = ApiListingUtil.mergeApiListing(existingApiListing, apiListing); } // controllers without any operations are excluded from the apiListingMap list if (apiListing.apis() != null && !apiListing.apis().isEmpty()) { apiListingMap.put(apiListing.resourcePath(), apiListing); } } return apiListingMap; }