Skip to content

Commit

Permalink
fix: Added Channel Ref to Operation
Browse files Browse the repository at this point in the history
  • Loading branch information
ctasada committed Jan 12, 2024
1 parent b9ac45d commit ebe286d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.github.stavshamir.springwolf.asyncapi.v3.bindings.MessageBinding;
import io.github.stavshamir.springwolf.asyncapi.v3.bindings.OperationBinding;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ChannelObject;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ChannelReference;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ServerReference;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageHeaders;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageObject;
Expand Down Expand Up @@ -189,9 +190,9 @@ private Operation buildOperation(AsyncOperation asyncOperation, Method method, S
MessageObject message = buildMessage(asyncOperation, method);

return Operation.builder()
.channel(ChannelReference.fromChannel(channelName))
.description(description)
.title(operationTitle)
// FIXME: We can use the message reference once everything else works
.messages(List.of(MessageReference.fromMessage(message)))
.bindings(opBinding)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
import io.github.stavshamir.springwolf.asyncapi.v3.bindings.MessageBinding;
import io.github.stavshamir.springwolf.asyncapi.v3.bindings.OperationBinding;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ChannelObject;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ChannelReference;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.Message;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageHeaders;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageObject;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessagePayload;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageReference;
import io.github.stavshamir.springwolf.asyncapi.v3.model.operation.Operation;
import io.github.stavshamir.springwolf.asyncapi.v3.model.operation.OperationAction;
import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.MultiFormatSchema;
import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.SchemaReference;
import io.github.stavshamir.springwolf.schemas.SchemasService;
Expand Down Expand Up @@ -164,7 +166,16 @@ private ChannelObject buildChannelItem(ClassAnnotation classAnnotation, Map<Stri
private Operation buildOperation(ClassAnnotation classAnnotation, Map<String, Message> messages) {
Map<String, OperationBinding> operationBinding = bindingFactory.buildOperationBinding(classAnnotation);
Map<String, OperationBinding> opBinding = operationBinding != null ? new HashMap<>(operationBinding) : null;
String channelName = bindingFactory.getChannelName(classAnnotation);

// var messageReferences = messages.values().stream().map(m -> MessageReference.fromMessage(m)).toList();

// FIXME
return Operation.builder().bindings(opBinding) /*.messages(messages)*/.build();
return Operation.builder()
.action(OperationAction.RECEIVE)
.channel(ChannelReference.fromChannel(channelName))
// .messages(messageReferences)
.bindings(opBinding)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
import io.github.stavshamir.springwolf.asyncapi.v3.bindings.MessageBinding;
import io.github.stavshamir.springwolf.asyncapi.v3.bindings.OperationBinding;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ChannelObject;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ChannelReference;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageHeaders;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageObject;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessagePayload;
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageReference;
import io.github.stavshamir.springwolf.asyncapi.v3.model.operation.Operation;
import io.github.stavshamir.springwolf.asyncapi.v3.model.operation.OperationAction;
import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.MultiFormatSchema;
import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.SchemaReference;
import io.github.stavshamir.springwolf.schemas.SchemasService;
Expand Down Expand Up @@ -132,8 +134,11 @@ private ChannelObject buildChannelItem(MethodAnnotation annotation, MessageObjec
private Operation buildOperation(MethodAnnotation annotation, MessageObject message) {
Map<String, OperationBinding> operationBinding = bindingFactory.buildOperationBinding(annotation);
Map<String, OperationBinding> opBinding = operationBinding != null ? new HashMap<>(operationBinding) : null;
String channelName = bindingFactory.getChannelName(annotation);

return Operation.builder()
.action(OperationAction.RECEIVE)
.channel(ChannelReference.fromChannel(channelName))
.messages(List.of(MessageReference.fromMessage(message)))
.bindings(opBinding)
.build();
Expand Down

0 comments on commit ebe286d

Please sign in to comment.