use of org.glassfish.hk2.classmodel.reflect.AnnotatedElement in project Payara by payara.
the class ApplicationProcessor method visitExternalDocumentation.
@Override
public void visitExternalDocumentation(AnnotationModel externalDocs, AnnotatedElement element, ApiContext context) {
if (element instanceof MethodModel) {
ExternalDocumentation newExternalDocs = new ExternalDocumentationImpl();
ExternalDocumentationImpl.merge(ExternalDocumentationImpl.createInstance(externalDocs), newExternalDocs, true);
if (newExternalDocs.getUrl() != null && !newExternalDocs.getUrl().isEmpty()) {
context.getWorkingOperation().setExternalDocs(newExternalDocs);
}
}
}
use of org.glassfish.hk2.classmodel.reflect.AnnotatedElement in project Payara by payara.
the class ApplicationProcessor method visitTag.
@Override
public void visitTag(AnnotationModel annotation, AnnotatedElement element, ApiContext context) {
Tag from = TagImpl.createInstance(annotation, context);
if (element instanceof MethodModel) {
final List<Tag> tags = new ArrayList<>();
tags.addAll(context.getApi().getTags());
TagImpl.merge(from, context.getWorkingOperation(), true, tags);
context.getApi().setTags(tags);
} else {
Tag newTag = new TagImpl();
TagImpl.merge(from, newTag, true);
if (newTag.getName() != null && !newTag.getName().isEmpty()) {
context.getApi().addTag(newTag);
}
}
}
use of org.glassfish.hk2.classmodel.reflect.AnnotatedElement in project Payara by payara.
the class ApplicationProcessor method createSchema.
private Schema createSchema(Schema schema, ApiContext context, ParameterizedType type) {
String typeName = type.getTypeName();
List<ParameterizedType> genericTypes = type.getParameterizedTypes();
SchemaType schemaType = ModelUtils.getSchemaType(type, context);
if (schema == null) {
schema = new SchemaImpl();
schema.setType(schemaType);
}
// Set the subtype if it's an array (for example an array of ints)
if (schemaType == SchemaType.ARRAY) {
if (type.isArray()) {
schemaType = ModelUtils.getSchemaType(type.getTypeName(), context);
schema.setType(schemaType);
} else if (!genericTypes.isEmpty()) {
// should be something Iterable
schema.setItems(createSchema(context, genericTypes.get(0)));
}
}
// If the schema is an object, insert the reference
if (schemaType == SchemaType.OBJECT) {
if (insertObjectReference(context, schema, type.getType(), typeName)) {
schema.setType(null);
schema.setItems(null);
}
}
if (type instanceof AnnotatedElement) {
AnnotatedElement element = (AnnotatedElement) type;
final AnnotationModel schemaAnnotation = element.getAnnotation(org.eclipse.microprofile.openapi.annotations.media.Schema.class.getName());
if (schemaAnnotation != null) {
SchemaImpl.merge(SchemaImpl.createInstance(schemaAnnotation, context), schema, false, context);
}
}
return schema;
}
use of org.glassfish.hk2.classmodel.reflect.AnnotatedElement in project Payara by payara.
the class ApplicationProcessor method visitTags.
@Override
public void visitTags(AnnotationModel annotation, AnnotatedElement element, ApiContext context) {
if (element instanceof MethodModel) {
List<AnnotationModel> tags = annotation.getValue("value", List.class);
if (tags != null) {
for (AnnotationModel tag : tags) {
visitTag(tag, element, context);
}
}
List<String> refs = annotation.getValue("refs", List.class);
if (refs != null) {
for (String ref : refs) {
if (ref != null && !ref.isEmpty()) {
context.getWorkingOperation().addTag(ref);
}
}
}
}
}
use of org.glassfish.hk2.classmodel.reflect.AnnotatedElement in project Payara by payara.
the class ApplicationProcessor method findParameterizedModelFromGenerics.
private ParameterizedInterfaceModel findParameterizedModelFromGenerics(ExtensibleType<? extends ExtensibleType> annotatedElement, Collection<ParameterizedInterfaceModel> parameterizedModels, ParameterizedType genericType) {
if (parameterizedModels == null || parameterizedModels.isEmpty()) {
return null;
}
List<String> formalParamKeys = new ArrayList<>(annotatedElement.getFormalTypeParameters().keySet());
int i = 0;
for (ParameterizedInterfaceModel parameterizedModel : parameterizedModels) {
if (formalParamKeys.get(i).equals(genericType.getFormalType())) {
return parameterizedModel;
}
i++;
}
return null;
}
Aggregations