diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/annotations/AsyncOperation.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/annotations/AsyncOperation.java index 0e5ed7747..71a606f42 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/annotations/AsyncOperation.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/annotations/AsyncOperation.java @@ -54,7 +54,7 @@ String description() default ""; - String value(); + String value() default ""; } } } diff --git a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AsyncAnnotationUtil.java b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AsyncAnnotationUtil.java index 38bdb96b2..7963121b6 100644 --- a/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AsyncAnnotationUtil.java +++ b/springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AsyncAnnotationUtil.java @@ -74,6 +74,7 @@ private static List getHeaderValues( List value, StringValueResolver resolver) { return value.stream() .map(AsyncOperation.Headers.Header::value) + .filter(StringUtils::hasText) .map(resolver::resolveStringValue) .sorted() .toList(); diff --git a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AsyncAnnotationUtilTest.java b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AsyncAnnotationUtilTest.java index 27aaa0a27..e67a5762a 100644 --- a/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AsyncAnnotationUtilTest.java +++ b/springwolf-core/src/test/java/io/github/springwolf/core/asyncapi/scanners/common/utils/AsyncAnnotationUtilTest.java @@ -50,11 +50,23 @@ void getAsyncHeaders(Class classWithOperationBindingProcessor) throws NoSuchM SchemaObject headers = AsyncAnnotationUtil.getAsyncHeaders(operation, resolver); assertEquals("TestSchema", headers.getTitle()); assertEquals("header-descriptionResolved", headers.getDescription()); - assertTrue(headers.getProperties().containsKey("headerResolved")); + assertTrue( + headers.getProperties().containsKey("headerResolved"), + headers.getProperties() + " does not contain key 'headerResolved'"); SchemaObject headerResolved = (SchemaObject) headers.getProperties().get("headerResolved"); assertEquals("string", headerResolved.getType()); assertEquals("valueResolved", headerResolved.getExamples().get(0)); assertEquals("descriptionResolved", headerResolved.getDescription()); + + assertTrue( + headers.getProperties().containsKey("headerWithoutValueResolved"), + headers.getProperties() + " does not contain key 'headerWithoutValueResolved'"); + SchemaObject headerWithoutValueResolved = + (SchemaObject) headers.getProperties().get("headerWithoutValueResolved"); + assertEquals("string", headerWithoutValueResolved.getType()); + assertTrue(headerWithoutValueResolved.getExamples().isEmpty()); + assertTrue(headerWithoutValueResolved.getEnumValues().isEmpty()); + assertEquals("descriptionResolved", headerWithoutValueResolved.getDescription()); } @Test @@ -215,6 +227,9 @@ private static class ClassWithOperationBindingProcessor { @AsyncOperation.Headers.Header( name = "header", value = "value", + description = "description"), + @AsyncOperation.Headers.Header( + name = "headerWithoutValue", description = "description") }))) @TestOperationBindingProcessor.TestOperationBinding() @@ -259,6 +274,9 @@ private static class ClassWithAbstractOperationBindingProcessor { @AsyncOperation.Headers.Header( name = "header", value = "value", + description = "description"), + @AsyncOperation.Headers.Header( + name = "headerWithoutValue", description = "description") }))) @TestAbstractOperationBindingProcessor.TestOperationBinding()