From b654512b37ec731da3e5a87231d484e55342b9bf Mon Sep 17 00:00:00 2001 From: Michael Edgar Date: Sat, 11 Mar 2023 08:44:20 -0500 Subject: [PATCH] Resolve wildcard bound in terminal type check For quarkusio/quarkus#31744 Signed-off-by: Michael Edgar --- .../io/smallrye/openapi/runtime/util/TypeUtil.java | 4 +++- .../openapi/runtime/io/schema/SchemaFactoryTest.java | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/io/smallrye/openapi/runtime/util/TypeUtil.java b/core/src/main/java/io/smallrye/openapi/runtime/util/TypeUtil.java index 9d3a2d470..c00c57189 100644 --- a/core/src/main/java/io/smallrye/openapi/runtime/util/TypeUtil.java +++ b/core/src/main/java/io/smallrye/openapi/runtime/util/TypeUtil.java @@ -506,9 +506,11 @@ public static boolean isTerminalType(Type type) { terminal = true; break; case TYPE_VARIABLE: - case WILDCARD_TYPE: terminal = false; break; + case WILDCARD_TYPE: + terminal = isTerminalType(resolveWildcard(type)); + break; case CLASS: if (DOTNAME_OBJECT.equals(type.name())) { terminal = true; diff --git a/core/src/test/java/io/smallrye/openapi/runtime/io/schema/SchemaFactoryTest.java b/core/src/test/java/io/smallrye/openapi/runtime/io/schema/SchemaFactoryTest.java index 69589ec34..bd23ccd25 100644 --- a/core/src/test/java/io/smallrye/openapi/runtime/io/schema/SchemaFactoryTest.java +++ b/core/src/test/java/io/smallrye/openapi/runtime/io/schema/SchemaFactoryTest.java @@ -1,14 +1,17 @@ package io.smallrye.openapi.runtime.io.schema; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import java.util.Collections; import java.util.concurrent.CompletableFuture; +import org.eclipse.microprofile.openapi.models.media.Schema; import org.jboss.jandex.DotName; import org.jboss.jandex.Index; import org.jboss.jandex.ParameterizedType; import org.jboss.jandex.Type; +import org.jboss.jandex.WildcardType; import org.junit.jupiter.api.Test; import io.smallrye.openapi.api.util.ClassLoaderUtil; @@ -30,4 +33,13 @@ void testResolveAsyncType() { assertEquals(STRING_TYPE, result); } + @Test + void testWildcardSchemaIsEmpty() { + Index index = indexOf(); + AnnotationScannerContext context = new AnnotationScannerContext(index, ClassLoaderUtil.getDefaultClassLoader(), + emptyConfig()); + Type type = WildcardType.create(null, false); + Schema result = SchemaFactory.typeToSchema(context, type, null, Collections.emptyList()); + assertNull(result.getType()); + } }