Skip to content
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

#814 added support for descriptions from java interfaces #815

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.*;

import com.buschmais.jqassistant.core.shared.annotation.Description;

import com.fasterxml.classmate.ResolvedType;
import com.fasterxml.jackson.databind.JsonNode;
Expand Down Expand Up @@ -40,20 +39,31 @@ public static ObjectNode generateSchema(Class<?> clazz) {
.without(Option.VOID_METHODS, Option.GETTER_METHODS, Option.PUBLIC_STATIC_FIELDS);

configBuilder.forMethods()
.withTargetTypeOverridesResolver(target -> getResolvedTypes(target, target.getType()));
configBuilder.forMethods()
.withPropertyNameOverrideResolver(member -> mapToKebabCase(member.getName()));
configBuilder.forTypesInGeneral()
.withCustomDefinitionProvider(new MapDefinitionProvider());
configBuilder.forMethods()
.withTargetTypeOverridesResolver(target -> getResolvedTypes(target, target.getType()))
.withPropertyNameOverrideResolver(member -> mapToKebabCase(member.getName()))
.withDefaultResolver(method -> {
WithDefault annotation = method.getAnnotationConsideringFieldAndGetter(WithDefault.class);
if (annotation != null) {
return annotation.value();
}
return null;
})
.withDescriptionResolver(method -> {
Description annotation = method.getAnnotationConsideringFieldAndGetter(Description.class);
if (annotation != null) {
return annotation.value();
}
if (method.getType() != null) {
Description innerAnnotation = method.getType().getErasedType().getAnnotation(Description.class);
if (innerAnnotation != null) {
return innerAnnotation.value();
}
}
return null;
});

configBuilder.forTypesInGeneral()
.withCustomDefinitionProvider(new MapDefinitionProvider())
.withDefinitionNamingStrategy((definitionKey, context) -> mapToKebabCase(definitionKey.getType()
.getTypeName()));

Expand Down
Loading