diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/channels/CloudStreamFunctionChannelsScanner.java b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/channels/CloudStreamFunctionChannelsScanner.java index 75637ee6f..2d1d43512 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/channels/CloudStreamFunctionChannelsScanner.java +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/channels/CloudStreamFunctionChannelsScanner.java @@ -20,7 +20,7 @@ import io.github.springwolf.core.asyncapi.scanners.bindings.channels.ChannelBindingProcessor; import io.github.springwolf.core.asyncapi.scanners.bindings.messages.MessageBindingProcessor; import io.github.springwolf.core.asyncapi.scanners.channels.ChannelMerger; -import io.github.springwolf.core.asyncapi.scanners.classes.spring.ComponentClassScanner; +import io.github.springwolf.core.asyncapi.scanners.classes.SpringwolfClassScanner; import io.github.springwolf.core.asyncapi.scanners.common.utils.AsyncAnnotationUtil; import io.github.springwolf.core.configuration.docket.AsyncApiDocket; import io.github.springwolf.core.configuration.docket.AsyncApiDocketService; @@ -42,7 +42,7 @@ public class CloudStreamFunctionChannelsScanner implements ChannelsScanner { private final AsyncApiDocketService asyncApiDocketService; private final BeanMethodsScanner beanMethodsScanner; - private final ComponentClassScanner componentClassScanner; + private final SpringwolfClassScanner classScanner; private final ComponentsService componentsService; private final BindingServiceProperties cloudStreamBindingsProperties; private final FunctionalChannelBeanBuilder functionalChannelBeanBuilder; @@ -52,7 +52,7 @@ public class CloudStreamFunctionChannelsScanner implements ChannelsScanner { @Override public Map scan() { Set elements = new HashSet<>(); - elements.addAll(componentClassScanner.scan()); + elements.addAll(classScanner.scan()); elements.addAll(beanMethodsScanner.getBeanMethods()); List> channels = elements.stream() diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/common/FunctionalChannelBeanBuilder.java b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/common/FunctionalChannelBeanBuilder.java index c8dfd9427..b63ffc872 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/common/FunctionalChannelBeanBuilder.java +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/common/FunctionalChannelBeanBuilder.java @@ -25,19 +25,20 @@ public class FunctionalChannelBeanBuilder { public Set build(AnnotatedElement element) { Class type = getRawType(element); - if (Consumer.class.isAssignableFrom(type)) { - Class payloadType = getTypeGenerics(element).get(0); + List> typeGenerics = getTypeGenerics(element); + if (Consumer.class.isAssignableFrom(type) && typeGenerics.size() >= 1) { + Class payloadType = typeGenerics.get(0); return Set.of(ofConsumer(element, payloadType)); } - if (Supplier.class.isAssignableFrom(type)) { - Class payloadType = getTypeGenerics(element).get(0); + if (Supplier.class.isAssignableFrom(type) && typeGenerics.size() >= 1) { + Class payloadType = typeGenerics.get(0); return Set.of(ofSupplier(element, payloadType)); } - if (Function.class.isAssignableFrom(type)) { - Class inputType = getTypeGenerics(element).get(0); - Class outputType = getTypeGenerics(element).get(1); + if (Function.class.isAssignableFrom(type) && typeGenerics.size() >= 2) { + Class inputType = typeGenerics.get(0); + Class outputType = typeGenerics.get(1); return Set.of(ofConsumer(element, inputType), ofSupplier(element, outputType)); } @@ -89,8 +90,11 @@ private static String getElementName(AnnotatedElement element) { private List> getTypeGenerics(AnnotatedElement element) { if (element instanceof Method m) { - ParameterizedType genericReturnType = (ParameterizedType) m.getGenericReturnType(); - return getTypeGenerics(genericReturnType); + if (m.getGenericReturnType() instanceof ParameterizedType) { + ParameterizedType genericReturnType = (ParameterizedType) m.getGenericReturnType(); + return getTypeGenerics(genericReturnType); + } + return Collections.emptyList(); } if (element instanceof Class c) { diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/operations/CloudStreamFunctionOperationsScanner.java b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/operations/CloudStreamFunctionOperationsScanner.java index a7e0b53b6..dc98f6d86 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/operations/CloudStreamFunctionOperationsScanner.java +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/operations/CloudStreamFunctionOperationsScanner.java @@ -17,7 +17,7 @@ import io.github.springwolf.core.asyncapi.components.headers.AsyncHeadersNotDocumented; import io.github.springwolf.core.asyncapi.scanners.OperationsScanner; import io.github.springwolf.core.asyncapi.scanners.beans.BeanMethodsScanner; -import io.github.springwolf.core.asyncapi.scanners.classes.spring.ComponentClassScanner; +import io.github.springwolf.core.asyncapi.scanners.classes.SpringwolfClassScanner; import io.github.springwolf.core.asyncapi.scanners.operations.OperationMerger; import io.github.springwolf.core.configuration.docket.AsyncApiDocket; import io.github.springwolf.core.configuration.docket.AsyncApiDocketService; @@ -39,7 +39,7 @@ public class CloudStreamFunctionOperationsScanner implements OperationsScanner { private final AsyncApiDocketService asyncApiDocketService; private final BeanMethodsScanner beanMethodsScanner; - private final ComponentClassScanner componentClassScanner; + private final SpringwolfClassScanner classScanner; private final ComponentsService componentsService; private final BindingServiceProperties cloudStreamBindingsProperties; private final FunctionalChannelBeanBuilder functionalChannelBeanBuilder; @@ -47,7 +47,7 @@ public class CloudStreamFunctionOperationsScanner implements OperationsScanner { @Override public Map scan() { Set elements = new HashSet<>(); - elements.addAll(componentClassScanner.scan()); + elements.addAll(classScanner.scan()); elements.addAll(beanMethodsScanner.getBeanMethods()); List> operations = elements.stream() diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/configuration/SpringwolfCloudStreamAutoConfiguration.java b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/configuration/SpringwolfCloudStreamAutoConfiguration.java index b10d537f1..42569ac19 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/configuration/SpringwolfCloudStreamAutoConfiguration.java +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/src/main/java/io/github/springwolf/plugins/cloudstream/configuration/SpringwolfCloudStreamAutoConfiguration.java @@ -5,7 +5,7 @@ import io.github.springwolf.core.asyncapi.scanners.beans.BeanMethodsScanner; import io.github.springwolf.core.asyncapi.scanners.bindings.channels.ChannelBindingProcessor; import io.github.springwolf.core.asyncapi.scanners.bindings.messages.MessageBindingProcessor; -import io.github.springwolf.core.asyncapi.scanners.classes.spring.ComponentClassScanner; +import io.github.springwolf.core.asyncapi.scanners.classes.SpringwolfClassScanner; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadClassExtractor; import io.github.springwolf.core.configuration.docket.AsyncApiDocketService; import io.github.springwolf.core.configuration.properties.SpringwolfConfigConstants; @@ -30,7 +30,7 @@ public class SpringwolfCloudStreamAutoConfiguration { public CloudStreamFunctionChannelsScanner cloudStreamFunctionChannelsScanner( AsyncApiDocketService asyncApiDocketService, BeanMethodsScanner beanMethodsScanner, - ComponentClassScanner componentClassScanner, + SpringwolfClassScanner classScanner, ComponentsService componentsService, BindingServiceProperties cloudstreamBindingServiceProperties, FunctionalChannelBeanBuilder functionalChannelBeanBuilder, @@ -39,7 +39,7 @@ public CloudStreamFunctionChannelsScanner cloudStreamFunctionChannelsScanner( return new CloudStreamFunctionChannelsScanner( asyncApiDocketService, beanMethodsScanner, - componentClassScanner, + classScanner, componentsService, cloudstreamBindingServiceProperties, functionalChannelBeanBuilder, @@ -51,14 +51,14 @@ public CloudStreamFunctionChannelsScanner cloudStreamFunctionChannelsScanner( public CloudStreamFunctionOperationsScanner cloudStreamFunctionOperationsScanner( AsyncApiDocketService asyncApiDocketService, BeanMethodsScanner beanMethodsScanner, - ComponentClassScanner componentClassScanner, + SpringwolfClassScanner classScanner, ComponentsService componentsService, BindingServiceProperties cloudstreamBindingServiceProperties, FunctionalChannelBeanBuilder functionalChannelBeanBuilder) { return new CloudStreamFunctionOperationsScanner( asyncApiDocketService, beanMethodsScanner, - componentClassScanner, + classScanner, componentsService, cloudstreamBindingServiceProperties, functionalChannelBeanBuilder); diff --git a/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/channels/CloudStreamFunctionChannelsScannerIntegrationTest.java b/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/channels/CloudStreamFunctionChannelsScannerIntegrationTest.java index 9699e3f6b..fbc79648f 100644 --- a/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/channels/CloudStreamFunctionChannelsScannerIntegrationTest.java +++ b/springwolf-plugins/springwolf-cloud-stream-plugin/src/test/java/io/github/springwolf/plugins/cloudstream/asyncapi/scanners/channels/CloudStreamFunctionChannelsScannerIntegrationTest.java @@ -24,6 +24,7 @@ import io.github.springwolf.core.asyncapi.components.examples.walkers.json.ExampleJsonValueGenerator; import io.github.springwolf.core.asyncapi.components.headers.AsyncHeadersNotDocumented; import io.github.springwolf.core.asyncapi.scanners.beans.DefaultBeanMethodsScanner; +import io.github.springwolf.core.asyncapi.scanners.classes.SpringwolfClassScanner; import io.github.springwolf.core.asyncapi.scanners.classes.spring.ComponentClassScanner; import io.github.springwolf.core.asyncapi.scanners.classes.spring.ConfigurationClassScanner; import io.github.springwolf.core.asyncapi.scanners.common.payload.PayloadClassExtractor; @@ -60,7 +61,9 @@ @ContextConfiguration( classes = { ConfigurationClassScanner.class, + SpringwolfClassScanner.class, ComponentClassScanner.class, + ConfigurationClassScanner.class, DefaultBeanMethodsScanner.class, DefaultComponentsService.class, SwaggerSchemaUtil.class,