Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): Make @AsyncOperation.Headers.Header#value optional #798

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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