use of com.github.javaparser.ast.type.ClassOrInterfaceType in project flow by vaadin.
the class OpenAPIObjectGenerator method parseNonEndpointClassAsSchema.
private List<Schema> parseNonEndpointClassAsSchema(String fullQualifiedName) {
TypeDeclaration<?> typeDeclaration = nonEndpointMap.get(fullQualifiedName);
if (typeDeclaration == null || typeDeclaration.isEnumDeclaration()) {
return Collections.emptyList();
}
List<Schema> result = new ArrayList<>();
Schema schema = schemaGenerator.createSingleSchema(fullQualifiedName, typeDeclaration);
generatedSchema.add(fullQualifiedName);
NodeList<ClassOrInterfaceType> extendedTypes = null;
if (typeDeclaration.isClassOrInterfaceDeclaration()) {
extendedTypes = typeDeclaration.asClassOrInterfaceDeclaration().getExtendedTypes();
}
if (extendedTypes == null || extendedTypes.isEmpty()) {
result.add(schema);
result.addAll(generatedRelatedSchemas(schema));
} else {
ComposedSchema parentSchema = new ComposedSchema();
parentSchema.setName(fullQualifiedName);
result.add(parentSchema);
extendedTypes.forEach(parentType -> {
GeneratorType type = new GeneratorType(parentType.resolve());
String parentQualifiedName = type.asResolvedType().asReferenceType().getQualifiedName();
String parentRef = SchemaResolver.getFullQualifiedNameRef(parentQualifiedName);
parentSchema.addAllOfItem(new ObjectSchema().$ref(parentRef));
usedTypes.put(parentQualifiedName, type);
});
// The inserting order matters for `allof` property.
parentSchema.addAllOfItem(schema);
result.addAll(generatedRelatedSchemas(parentSchema));
}
return result;
}
Aggregations