@Override public String findPropertyDescription(Annotated a) { ApiParam apiParam = a.getAnnotation(ApiParam.class); if (apiParam != null) { return apiParam.description(); } ApiModel model = a.getAnnotation(ApiModel.class); if (model != null && !"".equals(model.description())) { return model.description(); } ApiModelProperty prop = a.getAnnotation(ApiModelProperty.class); if (prop != null) { return prop.value(); } return null; }
@Override public List<NamedType> findSubtypes(Annotated a) { final ApiModel api = a.getAnnotation(ApiModel.class); if (api != null) { final Class<?>[] classes = api.subTypes(); final List<NamedType> names = new ArrayList<>(classes.length); for (Class<?> subType : classes) { names.add(new NamedType(subType)); } if (!names.isEmpty()) { return names; } } return Collections.emptyList(); }
@Override public PropertyName findRootName(AnnotatedClass ac) { ApiModel model = ac.getAnnotation(ApiModel.class); if (model != null) { return new PropertyName(model.value()); } else { return super.findRootName(ac); } }
@Override public void process(final CtClass<?> element) { final CtAnnotation<Annotation> annotation = getFactory().Code().createAnnotation(getFactory().Code().createCtTypeReference(ApiModel.class)); element.addAnnotation(annotation); log.debug("Add ApiModel to {}", element.getQualifiedName()); }
public static String calculateTypeName(Class<?> parameterType) { String typeName = typeNameByClass.get(parameterType); if (typeName != null) { return typeName; } if (parameterType.isPrimitive() || parameterType.getPackage().getName().equals("java.lang")) { return "string"; } if (parameterType.getName().equals("com.sun.jersey.multipart.MultiPart")) { return "File"; } ApiModel apiModel = parameterType.getAnnotation(ApiModel.class); typeName = apiModel == null ? null : Strings.emptyToNull(apiModel.value()); return MoreObjects.firstNonNull(typeName, parameterType.getSimpleName()); }