diff --git a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/TypeResolver.java b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/TypeResolver.java index f01b66e79..299ea3c8a 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/TypeResolver.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/scanner/dataobject/TypeResolver.java @@ -185,6 +185,11 @@ private TypeResolver(AnnotationScannerContext context, UnaryOperator nam } } + private void replaceResolutionStack(Deque> replacementStack) { + resolutionStack.clear(); + resolutionStack.addAll(replacementStack); + } + /** * Get the declaring class of the annotation target. * @@ -525,10 +530,7 @@ public static Map getAllFields(AnnotationScannerContext co for (Map.Entry entry : chain.entrySet()) { ClassInfo currentClass = entry.getKey(); Type currentType = entry.getValue(); - - if (currentType.kind() == Type.Kind.PARAMETERIZED_TYPE) { - stack.push(buildParamTypeResolutionMap(currentClass, currentType)); - } + maybeAddResolutionParams(stack, currentType, currentClass); if (skipPropertyScan || (!currentType.equals(leaf) && TypeUtil.isAllOf(context, leafKlazz, currentType)) || TypeUtil.knownJavaType(currentClass.name())) { @@ -556,7 +558,11 @@ public static Map getAllFields(AnnotationScannerContext co index.interfaces(currentClass) .stream() .filter(type -> !TypeUtil.knownJavaType(type.name())) - .map(index::getClass) + .map(type -> { + ClassInfo clazz = index.getClass(type); + maybeAddResolutionParams(stack, type, clazz); + return clazz; + }) .filter(Objects::nonNull) .flatMap(clazz -> methods(context, clazz).stream()) .filter(method -> method.name().chars().allMatch(Character::isJavaIdentifierPart)) @@ -578,6 +584,12 @@ public static Map getAllFields(AnnotationScannerContext co return sorted(context, properties, chain.keySet()); } + private static void maybeAddResolutionParams(Deque> stack, Type type, ClassInfo clazz) { + if (type.kind() == Type.Kind.PARAMETERIZED_TYPE && clazz != null) { + stack.push(buildParamTypeResolutionMap(clazz, type)); + } + } + private static List methods(AnnotationScannerContext context, ClassInfo currentClass) { if (context.getConfig().sortedPropertiesEnable()) { return currentClass.methods(); @@ -935,9 +947,10 @@ private static TypeResolver updateTypeResolvers(AnnotationScannerContext context if (properties.containsKey(propertyName)) { resolver = properties.get(propertyName); + Type resolvedPropertyType = getResolvedType(propertyType, stack); // Only store the accessor/mutator methods if the type of property matches - if (!TypeUtil.equalTypes(resolver.getUnresolvedType(), propertyType)) { + if (!TypeUtil.equalTypes(resolver.resolveType(), resolvedPropertyType)) { return resolver; } } else { @@ -951,10 +964,12 @@ private static TypeResolver updateTypeResolvers(AnnotationScannerContext context if (isWriteMethod) { if (isHigherPriority(resolver.targetComparator, method, resolver.getWriteMethod())) { resolver.setWriteMethod(method); + resolver.replaceResolutionStack(stack); } } else { if (isHigherPriority(resolver.targetComparator, method, resolver.getReadMethod())) { resolver.setReadMethod(method); + resolver.replaceResolutionStack(stack); } }