Skip to content

Commit

Permalink
fix(core): extract AsyncMessage#description
Browse files Browse the repository at this point in the history
Co-authored-by: David Müller <[email protected]>
  • Loading branch information
timonback and sam0r040 committed Apr 19, 2024
1 parent 0e4b9d2 commit 858c2b1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,20 @@ protected MessageObject buildMessage(AsyncOperation operationData, Method method
.schema(SchemaReference.fromSchema(payloadSchema.name()))
.build());

String description = operationData.message().description();
if (!StringUtils.hasText(description)) {
description = payloadSchema.schema().getDescription();
}
if (StringUtils.hasText(description)) {
description = this.resolver.resolveStringValue(description);
// TODO: description = TextUtils.do(description);
}

var builder = MessageObject.builder()
.messageId(payloadSchema.name())
.name(payloadSchema.name())
.title(payloadSchema.schema().getTitle())
.description(payloadSchema
.schema()
.getDescription()) // FIXME: Why do we set the payload description on the message?
.description(description)
.payload(messagePayload)
.headers(headers)
.bindings(messageBinding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ public class XmlConsumer {
operation =
@AsyncOperation(
channelName = "xml-topic",
description = "Showcases a xml based message",
message = @AsyncMessage(contentType = "text/xml")))
message =
@AsyncMessage(
contentType = "text/xml",
description = "Showcases a xml based message")))
@KafkaAsyncOperationBinding
@KafkaListener(topics = "xml-topic")
public void receiveExamplePayload(XmlPayloadDto payload) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ public class YamlConsumer {
operation =
@AsyncOperation(
channelName = "yaml-topic",
description = "Showcases a yaml based message",
message = @AsyncMessage(contentType = "application/yaml")))
message =
@AsyncMessage(
contentType = "application/yaml",
description = "Showcases a yaml based message")))
@KafkaAsyncOperationBinding
@KafkaListener(topics = "yaml-topic")
public void receiveExamplePayload(YamlPayloadDto payload) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,7 @@
"contentType": "text/xml",
"name": "io.github.springwolf.examples.kafka.dtos.XmlPayloadDto",
"title": "XmlPayloadDto",
"description": "Showcases a xml based message",
"bindings": {
"kafka": {
"bindingVersion": "0.5.0"
Expand All @@ -1328,6 +1329,7 @@
"contentType": "application/yaml",
"name": "io.github.springwolf.examples.kafka.dtos.YamlPayloadDto",
"title": "YamlPayloadDto",
"description": "Showcases a yaml based message",
"bindings": {
"kafka": {
"bindingVersion": "0.5.0"
Expand Down Expand Up @@ -1546,7 +1548,7 @@
"$ref": "#/channels/xml-topic"
},
"title": "xml-topic_receive",
"description": "Showcases a xml based message",
"description": "Auto-generated description",
"bindings": {
"kafka": {
"bindingVersion": "0.5.0"
Expand All @@ -1564,7 +1566,7 @@
"$ref": "#/channels/yaml-topic"
},
"title": "yaml-topic_receive",
"description": "Showcases a yaml based message",
"description": "Auto-generated description",
"bindings": {
"kafka": {
"bindingVersion": "0.5.0"
Expand Down

0 comments on commit 858c2b1

Please sign in to comment.