Skip to content

Commit

Permalink
feat(core): Make @AsyncOperation.Headers.Header#value optional
Browse files Browse the repository at this point in the history
fixes #791
  • Loading branch information
ccudennec-otto committed Jun 10, 2024
1 parent dc6e019 commit 0bd6528
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

String description() default "";

String value();
String value() default "";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ private static List<String> getHeaderValues(
List<AsyncOperation.Headers.Header> value, StringValueResolver resolver) {
return value.stream()
.map(AsyncOperation.Headers.Header::value)
.filter(StringUtils::hasText)
.map(resolver::resolveStringValue)
.sorted()
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 0bd6528

Please sign in to comment.