Skip to content

Commit ed0514e

Browse files
timonbackctasada
andauthored
Feat/asyncapi v3 UI fixes (#539)
* fix: Added missing comparison code Those missing annotations were causing some tests to fail * fix: AMQP operation binding As per documentation, 'deliveryMode' can only be 1 or 2. The default value 0 was incorrect * fix: Added Channel Ref to Operation * test: update asyncapi.json files based on current state in the branch Generate asyncapi.actual.json files by running in _springwolf_examples_ folder: `../gradlew test --tests "**.ApiIntegrationTest" --continue` * test(kafka): update asyncapi model * feat(ui): move asyncapi v3 changes --------- Co-authored-by: Carlos Tasada <[email protected]>
1 parent e17bbde commit ed0514e

File tree

29 files changed

+641
-755
lines changed

29 files changed

+641
-755
lines changed

springwolf-asyncapi/src/main/java/io/github/stavshamir/springwolf/asyncapi/v3/model/channel/message/MessageHeaders.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
import io.github.stavshamir.springwolf.asyncapi.v3.jackson.model.channel.message.MessageHeadersSerializer;
66
import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.MultiFormatSchema;
77
import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.SchemaObject;
8+
import lombok.EqualsAndHashCode;
89
import lombok.Getter;
910

1011
@Getter
1112
@JsonSerialize(using = MessageHeadersSerializer.class)
13+
@EqualsAndHashCode
1214
public class MessageHeaders {
1315
private MultiFormatSchema multiFormatSchema;
1416
private SchemaObject schema;

springwolf-asyncapi/src/main/java/io/github/stavshamir/springwolf/asyncapi/v3/model/channel/message/MessagePayload.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
import io.github.stavshamir.springwolf.asyncapi.v3.jackson.model.channel.message.MessagePayloadSerializer;
66
import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.MultiFormatSchema;
77
import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.SchemaObject;
8+
import lombok.EqualsAndHashCode;
89
import lombok.Getter;
910

1011
@Getter
1112
@JsonSerialize(using = MessagePayloadSerializer.class)
13+
@EqualsAndHashCode
1214
public class MessagePayload {
1315
private MultiFormatSchema multiFormatSchema;
1416
private SchemaObject schema;

springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AsyncAnnotationChannelsScanner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import io.github.stavshamir.springwolf.asyncapi.v3.bindings.MessageBinding;
1414
import io.github.stavshamir.springwolf.asyncapi.v3.bindings.OperationBinding;
1515
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ChannelObject;
16+
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ChannelReference;
1617
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ServerReference;
1718
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageHeaders;
1819
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageObject;
@@ -189,9 +190,9 @@ private Operation buildOperation(AsyncOperation asyncOperation, Method method, S
189190
MessageObject message = buildMessage(asyncOperation, method);
190191

191192
return Operation.builder()
193+
.channel(ChannelReference.fromChannel(channelName))
192194
.description(description)
193195
.title(operationTitle)
194-
// FIXME: We can use the message reference once everything else works
195196
.messages(List.of(MessageReference.fromMessage(message)))
196197
.bindings(opBinding)
197198
.build();

springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelAnnotationChannelsScanner.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
import io.github.stavshamir.springwolf.asyncapi.v3.bindings.MessageBinding;
1010
import io.github.stavshamir.springwolf.asyncapi.v3.bindings.OperationBinding;
1111
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ChannelObject;
12+
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ChannelReference;
1213
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.Message;
1314
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageHeaders;
1415
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageObject;
1516
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessagePayload;
1617
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageReference;
1718
import io.github.stavshamir.springwolf.asyncapi.v3.model.operation.Operation;
19+
import io.github.stavshamir.springwolf.asyncapi.v3.model.operation.OperationAction;
1820
import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.MultiFormatSchema;
1921
import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.SchemaReference;
2022
import io.github.stavshamir.springwolf.schemas.SchemasService;
@@ -164,7 +166,16 @@ private ChannelObject buildChannelItem(ClassAnnotation classAnnotation, Map<Stri
164166
private Operation buildOperation(ClassAnnotation classAnnotation, Map<String, Message> messages) {
165167
Map<String, OperationBinding> operationBinding = bindingFactory.buildOperationBinding(classAnnotation);
166168
Map<String, OperationBinding> opBinding = operationBinding != null ? new HashMap<>(operationBinding) : null;
169+
String channelName = bindingFactory.getChannelName(classAnnotation);
170+
171+
// var messageReferences = messages.values().stream().map(m -> MessageReference.fromMessage(m)).toList();
172+
167173
// FIXME
168-
return Operation.builder().bindings(opBinding) /*.messages(messages)*/.build();
174+
return Operation.builder()
175+
.action(OperationAction.RECEIVE)
176+
.channel(ChannelReference.fromChannel(channelName))
177+
// .messages(messageReferences)
178+
.bindings(opBinding)
179+
.build();
169180
}
170181
}

springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelAnnotationChannelsScanner.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
import io.github.stavshamir.springwolf.asyncapi.v3.bindings.MessageBinding;
1010
import io.github.stavshamir.springwolf.asyncapi.v3.bindings.OperationBinding;
1111
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ChannelObject;
12+
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.ChannelReference;
1213
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageHeaders;
1314
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageObject;
1415
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessagePayload;
1516
import io.github.stavshamir.springwolf.asyncapi.v3.model.channel.message.MessageReference;
1617
import io.github.stavshamir.springwolf.asyncapi.v3.model.operation.Operation;
18+
import io.github.stavshamir.springwolf.asyncapi.v3.model.operation.OperationAction;
1719
import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.MultiFormatSchema;
1820
import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.SchemaReference;
1921
import io.github.stavshamir.springwolf.schemas.SchemasService;
@@ -132,8 +134,11 @@ private ChannelObject buildChannelItem(MethodAnnotation annotation, MessageObjec
132134
private Operation buildOperation(MethodAnnotation annotation, MessageObject message) {
133135
Map<String, OperationBinding> operationBinding = bindingFactory.buildOperationBinding(annotation);
134136
Map<String, OperationBinding> opBinding = operationBinding != null ? new HashMap<>(operationBinding) : null;
137+
String channelName = bindingFactory.getChannelName(annotation);
135138

136139
return Operation.builder()
140+
.action(OperationAction.RECEIVE)
141+
.channel(ChannelReference.fromChannel(channelName))
137142
.messages(List.of(MessageReference.fromMessage(message)))
138143
.bindings(opBinding)
139144
.build();

springwolf-examples/springwolf-amqp-example/src/test/resources/asyncapi.json

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"channels": {
2828
"another-queue": {
2929
"messages": {
30-
"another-queue_publish_receiveAnotherPayload.message": {
30+
"io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto": {
3131
"headers": {
3232
"$ref": "#/components/schemas/HeadersNotDocumented"
3333
},
@@ -69,7 +69,7 @@
6969
},
7070
"example-producer-channel-publisher": {
7171
"messages": {
72-
"example-producer-channel-publisher_subscribe.message": {
72+
"io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto": {
7373
"headers": {
7474
"$ref": "#/components/schemas/HeadersNotDocumented"
7575
},
@@ -92,7 +92,7 @@
9292
},
9393
"example-queue": {
9494
"messages": {
95-
"example-queue_publish_receiveExamplePayload.message": {
95+
"io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto": {
9696
"headers": {
9797
"$ref": "#/components/schemas/HeadersNotDocumented"
9898
},
@@ -134,7 +134,7 @@
134134
},
135135
"example-topic-routing-key": {
136136
"messages": {
137-
"example-topic-routing-key_publish_bindingsExample.message": {
137+
"io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto": {
138138
"headers": {
139139
"$ref": "#/components/schemas/HeadersNotDocumented"
140140
},
@@ -176,7 +176,7 @@
176176
},
177177
"multi-payload-queue": {
178178
"messages": {
179-
"multi-payload-queue_publish_bindingsBeanExample.message.0": {
179+
"io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto": {
180180
"headers": {
181181
"$ref": "#/components/schemas/HeadersNotDocumented"
182182
},
@@ -194,7 +194,7 @@
194194
}
195195
}
196196
},
197-
"multi-payload-queue_publish_bindingsBeanExample.message.1": {
197+
"io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto": {
198198
"headers": {
199199
"$ref": "#/components/schemas/HeadersNotDocumented"
200200
},
@@ -307,13 +307,9 @@
307307
},
308308
"operations": {
309309
"another-queue_publish_receiveAnotherPayload": {
310-
"action": "receive",
311-
"channel": {
312-
"$ref": "#/channels/another-queue"
313-
},
314-
"description": "Auto-generated description",
315310
"bindings": {
316311
"amqp": {
312+
"expiration": 0,
317313
"cc": [
318314
"another-queue"
319315
],
@@ -322,22 +318,20 @@
322318
},
323319
"messages": [
324320
{
325-
"$ref": "#/channels/another-queue/messages/another-queue_publish_receiveAnotherPayload.message"
321+
"$ref": "#/components/messages/io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto"
326322
}
327323
]
328324
},
329-
"example-producer-channel-publisher_subscribe": {
325+
"example-producer-channel-publisher": {
330326
"action": "send",
331-
"channel": {
332-
"$ref": "#/channels/example-producer-channel-publisher"
333-
},
327+
"title": "example-producer-channel-publisher_subscribe",
334328
"description": "Custom, optional description defined in the AsyncPublisher annotation",
335329
"bindings": {
336330
"amqp": {
337331
"expiration": 0,
338-
"cc": [],
332+
"cc": [ ],
339333
"priority": 0,
340-
"deliveryMode": 1,
334+
"deliveryMode": 0,
341335
"mandatory": false,
342336
"timestamp": false,
343337
"ack": false,
@@ -346,18 +340,14 @@
346340
},
347341
"messages": [
348342
{
349-
"$ref": "#/channels/example-producer-channel-publisher/messages/example-producer-channel-publisher_subscribe.message"
343+
"$ref": "#/components/messages/io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto"
350344
}
351345
]
352346
},
353347
"example-queue_publish_receiveExamplePayload": {
354-
"action": "receive",
355-
"channel": {
356-
"$ref": "#/channels/example-queue"
357-
},
358-
"description": "Auto-generated description",
359348
"bindings": {
360349
"amqp": {
350+
"expiration": 0,
361351
"cc": [
362352
"example-queue"
363353
],
@@ -366,18 +356,14 @@
366356
},
367357
"messages": [
368358
{
369-
"$ref": "#/channels/example-queue/messages/example-queue_publish_receiveExamplePayload.message"
359+
"$ref": "#/components/messages/io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto"
370360
}
371361
]
372362
},
373363
"example-topic-routing-key_publish_bindingsExample": {
374-
"action": "receive",
375-
"channel": {
376-
"$ref": "#/channels/example-topic-routing-key"
377-
},
378-
"description": "Auto-generated description",
379364
"bindings": {
380365
"amqp": {
366+
"expiration": 0,
381367
"cc": [
382368
"example-topic-routing-key"
383369
],
@@ -386,18 +372,14 @@
386372
},
387373
"messages": [
388374
{
389-
"$ref": "#/channels/example-topic-routing-key/messages/example-topic-routing-key_publish_bindingsExample.message"
375+
"$ref": "#/components/messages/io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto"
390376
}
391377
]
392378
},
393379
"multi-payload-queue_publish_bindingsBeanExample": {
394-
"action": "receive",
395-
"channel": {
396-
"$ref": "#/channels/multi-payload-queue"
397-
},
398-
"description": "Auto-generated description",
399380
"bindings": {
400381
"amqp": {
382+
"expiration": 0,
401383
"cc": [
402384
"example-topic-routing-key"
403385
],
@@ -406,10 +388,10 @@
406388
},
407389
"messages": [
408390
{
409-
"$ref": "#/channels/multi-payload-queue/messages/multi-payload-queue_publish_bindingsBeanExample.message.0"
391+
"$ref": "#/components/messages/io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto"
410392
},
411393
{
412-
"$ref": "#/channels/multi-payload-queue/messages/multi-payload-queue_publish_bindingsBeanExample.message.1"
394+
"$ref": "#/components/messages/io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto"
413395
}
414396
]
415397
}

0 commit comments

Comments
 (0)