From 531032b7ba7e7366520a17baae5b79ff33ae9c32 Mon Sep 17 00:00:00 2001 From: Carlos Tasada Date: Fri, 12 Jan 2024 23:07:58 +0100 Subject: [PATCH 1/6] fix: Added missing comparison code Those missing annotations were causing some tests to fail --- .../asyncapi/v3/model/channel/message/MessageHeaders.java | 2 ++ .../asyncapi/v3/model/channel/message/MessagePayload.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/springwolf-asyncapi/src/main/java/io/github/stavshamir/springwolf/asyncapi/v3/model/channel/message/MessageHeaders.java b/springwolf-asyncapi/src/main/java/io/github/stavshamir/springwolf/asyncapi/v3/model/channel/message/MessageHeaders.java index bb5c864bf..0740a5405 100644 --- a/springwolf-asyncapi/src/main/java/io/github/stavshamir/springwolf/asyncapi/v3/model/channel/message/MessageHeaders.java +++ b/springwolf-asyncapi/src/main/java/io/github/stavshamir/springwolf/asyncapi/v3/model/channel/message/MessageHeaders.java @@ -5,10 +5,12 @@ import io.github.stavshamir.springwolf.asyncapi.v3.jackson.model.channel.message.MessageHeadersSerializer; import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.MultiFormatSchema; import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.SchemaObject; +import lombok.EqualsAndHashCode; import lombok.Getter; @Getter @JsonSerialize(using = MessageHeadersSerializer.class) +@EqualsAndHashCode public class MessageHeaders { private MultiFormatSchema multiFormatSchema; private SchemaObject schema; diff --git a/springwolf-asyncapi/src/main/java/io/github/stavshamir/springwolf/asyncapi/v3/model/channel/message/MessagePayload.java b/springwolf-asyncapi/src/main/java/io/github/stavshamir/springwolf/asyncapi/v3/model/channel/message/MessagePayload.java index f43f9c696..04125cada 100644 --- a/springwolf-asyncapi/src/main/java/io/github/stavshamir/springwolf/asyncapi/v3/model/channel/message/MessagePayload.java +++ b/springwolf-asyncapi/src/main/java/io/github/stavshamir/springwolf/asyncapi/v3/model/channel/message/MessagePayload.java @@ -5,10 +5,12 @@ import io.github.stavshamir.springwolf.asyncapi.v3.jackson.model.channel.message.MessagePayloadSerializer; import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.MultiFormatSchema; import io.github.stavshamir.springwolf.asyncapi.v3.model.schema.SchemaObject; +import lombok.EqualsAndHashCode; import lombok.Getter; @Getter @JsonSerialize(using = MessagePayloadSerializer.class) +@EqualsAndHashCode public class MessagePayload { private MultiFormatSchema multiFormatSchema; private SchemaObject schema; From b9ac45d0f6a274ec79869a7bc2dcaf4bca5b460b Mon Sep 17 00:00:00 2001 From: Carlos Tasada Date: Fri, 12 Jan 2024 23:09:06 +0100 Subject: [PATCH 2/6] fix: AMQP operation binding As per documentation, 'deliveryMode' can only be 1 or 2. The default value 0 was incorrect --- .../operationdata/annotation/AmqpAsyncOperationBinding.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AmqpAsyncOperationBinding.java b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AmqpAsyncOperationBinding.java index 084d6de4f..c3b4ba09d 100644 --- a/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AmqpAsyncOperationBinding.java +++ b/springwolf-plugins/springwolf-amqp-plugin/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/operationdata/annotation/AmqpAsyncOperationBinding.java @@ -27,7 +27,7 @@ int priority() default 0; - int deliveryMode() default 0; + int deliveryMode() default 1; boolean mandatory() default false; From ebe286dc283aecf9f0fe857d7b69d9a9ca150da4 Mon Sep 17 00:00:00 2001 From: Carlos Tasada Date: Fri, 12 Jan 2024 23:50:52 +0100 Subject: [PATCH 3/6] fix: Added Channel Ref to Operation --- .../annotation/AsyncAnnotationChannelsScanner.java | 3 ++- .../ClassLevelAnnotationChannelsScanner.java | 13 ++++++++++++- .../MethodLevelAnnotationChannelsScanner.java | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AsyncAnnotationChannelsScanner.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AsyncAnnotationChannelsScanner.java index 7fe2ab2c5..68a15af3e 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AsyncAnnotationChannelsScanner.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/AsyncAnnotationChannelsScanner.java @@ -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; @@ -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(); diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelAnnotationChannelsScanner.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelAnnotationChannelsScanner.java index 0c94c03f5..2a44606cd 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelAnnotationChannelsScanner.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/ClassLevelAnnotationChannelsScanner.java @@ -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; @@ -164,7 +166,16 @@ private ChannelObject buildChannelItem(ClassAnnotation classAnnotation, Map messages) { Map operationBinding = bindingFactory.buildOperationBinding(classAnnotation); Map 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(); } } diff --git a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelAnnotationChannelsScanner.java b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelAnnotationChannelsScanner.java index 5e2df5aa1..d5b817646 100644 --- a/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelAnnotationChannelsScanner.java +++ b/springwolf-core/src/main/java/io/github/stavshamir/springwolf/asyncapi/scanners/channels/annotation/MethodLevelAnnotationChannelsScanner.java @@ -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; @@ -132,8 +134,11 @@ private ChannelObject buildChannelItem(MethodAnnotation annotation, MessageObjec private Operation buildOperation(MethodAnnotation annotation, MessageObject message) { Map operationBinding = bindingFactory.buildOperationBinding(annotation); Map 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(); From 05840914c7e37786838db244ea073f5857407d31 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Sat, 13 Jan 2024 11:07:18 +0100 Subject: [PATCH 4/6] 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` --- .../src/test/resources/asyncapi.json | 58 +- .../src/test/resources/asyncapi.json | 115 +--- .../src/test/resources/asyncapi.json | 151 +++-- .../src/test/resources/asyncapi.json | 533 +++++++++--------- .../src/test/resources/asyncapi.json | 116 +--- .../src/test/resources/asyncapi.json | 79 +-- 6 files changed, 411 insertions(+), 641 deletions(-) diff --git a/springwolf-examples/springwolf-amqp-example/src/test/resources/asyncapi.json b/springwolf-examples/springwolf-amqp-example/src/test/resources/asyncapi.json index 0642b0534..b5aafdced 100644 --- a/springwolf-examples/springwolf-amqp-example/src/test/resources/asyncapi.json +++ b/springwolf-examples/springwolf-amqp-example/src/test/resources/asyncapi.json @@ -27,7 +27,7 @@ "channels": { "another-queue": { "messages": { - "another-queue_publish_receiveAnotherPayload.message": { + "io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto": { "headers": { "$ref": "#/components/schemas/HeadersNotDocumented" }, @@ -69,7 +69,7 @@ }, "example-producer-channel-publisher": { "messages": { - "example-producer-channel-publisher_subscribe.message": { + "io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto": { "headers": { "$ref": "#/components/schemas/HeadersNotDocumented" }, @@ -92,7 +92,7 @@ }, "example-queue": { "messages": { - "example-queue_publish_receiveExamplePayload.message": { + "io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto": { "headers": { "$ref": "#/components/schemas/HeadersNotDocumented" }, @@ -134,7 +134,7 @@ }, "example-topic-routing-key": { "messages": { - "example-topic-routing-key_publish_bindingsExample.message": { + "io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto": { "headers": { "$ref": "#/components/schemas/HeadersNotDocumented" }, @@ -176,7 +176,7 @@ }, "multi-payload-queue": { "messages": { - "multi-payload-queue_publish_bindingsBeanExample.message.0": { + "io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto": { "headers": { "$ref": "#/components/schemas/HeadersNotDocumented" }, @@ -194,7 +194,7 @@ } } }, - "multi-payload-queue_publish_bindingsBeanExample.message.1": { + "io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto": { "headers": { "$ref": "#/components/schemas/HeadersNotDocumented" }, @@ -307,13 +307,9 @@ }, "operations": { "another-queue_publish_receiveAnotherPayload": { - "action": "receive", - "channel": { - "$ref": "#/channels/another-queue" - }, - "description": "Auto-generated description", "bindings": { "amqp": { + "expiration": 0, "cc": [ "another-queue" ], @@ -322,22 +318,20 @@ }, "messages": [ { - "$ref": "#/channels/another-queue/messages/another-queue_publish_receiveAnotherPayload.message" + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto" } ] }, - "example-producer-channel-publisher_subscribe": { + "example-producer-channel-publisher": { "action": "send", - "channel": { - "$ref": "#/channels/example-producer-channel-publisher" - }, + "title": "example-producer-channel-publisher_subscribe", "description": "Custom, optional description defined in the AsyncPublisher annotation", "bindings": { "amqp": { "expiration": 0, - "cc": [], + "cc": [ ], "priority": 0, - "deliveryMode": 1, + "deliveryMode": 0, "mandatory": false, "timestamp": false, "ack": false, @@ -346,18 +340,14 @@ }, "messages": [ { - "$ref": "#/channels/example-producer-channel-publisher/messages/example-producer-channel-publisher_subscribe.message" + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto" } ] }, "example-queue_publish_receiveExamplePayload": { - "action": "receive", - "channel": { - "$ref": "#/channels/example-queue" - }, - "description": "Auto-generated description", "bindings": { "amqp": { + "expiration": 0, "cc": [ "example-queue" ], @@ -366,18 +356,14 @@ }, "messages": [ { - "$ref": "#/channels/example-queue/messages/example-queue_publish_receiveExamplePayload.message" + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto" } ] }, "example-topic-routing-key_publish_bindingsExample": { - "action": "receive", - "channel": { - "$ref": "#/channels/example-topic-routing-key" - }, - "description": "Auto-generated description", "bindings": { "amqp": { + "expiration": 0, "cc": [ "example-topic-routing-key" ], @@ -386,18 +372,14 @@ }, "messages": [ { - "$ref": "#/channels/example-topic-routing-key/messages/example-topic-routing-key_publish_bindingsExample.message" + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto" } ] }, "multi-payload-queue_publish_bindingsBeanExample": { - "action": "receive", - "channel": { - "$ref": "#/channels/multi-payload-queue" - }, - "description": "Auto-generated description", "bindings": { "amqp": { + "expiration": 0, "cc": [ "example-topic-routing-key" ], @@ -406,10 +388,10 @@ }, "messages": [ { - "$ref": "#/channels/multi-payload-queue/messages/multi-payload-queue_publish_bindingsBeanExample.message.0" + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.amqp.dtos.ExamplePayloadDto" }, { - "$ref": "#/channels/multi-payload-queue/messages/multi-payload-queue_publish_bindingsBeanExample.message.1" + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.amqp.dtos.AnotherPayloadDto" } ] } diff --git a/springwolf-examples/springwolf-cloud-stream-example/src/test/resources/asyncapi.json b/springwolf-examples/springwolf-cloud-stream-example/src/test/resources/asyncapi.json index d53ebacf5..b675cf5f6 100644 --- a/springwolf-examples/springwolf-cloud-stream-example/src/test/resources/asyncapi.json +++ b/springwolf-examples/springwolf-cloud-stream-example/src/test/resources/asyncapi.json @@ -12,129 +12,27 @@ "license": { "name": "Apache License 2.0" }, - "tags": [], "x-generator": "springwolf" }, "defaultContentType": "application/json", "servers": { "kafka": { - "host": "kafka:29092", + "host": "localhost:50025", "protocol": "kafka" } }, "channels": { "another-topic": { - "address": "another-topic", - "messages": { - "another-topic_publish_consumerMethod.message": { - "name": "io.github.stavshamir.springwolf.example.cloudstream.dtos.AnotherPayloadDto", - "title": "AnotherPayloadDto", - "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", - "schema": { - "$ref": "#/components/schemas/AnotherPayloadDto" - } - }, - "headers": { - "$ref": "#/components/schemas/HeadersNotDocumented" - }, - "bindings": { - "kafka": {} - } - }, - "another-topic_subscribe_process.message": { - "name": "io.github.stavshamir.springwolf.example.cloudstream.dtos.AnotherPayloadDto", - "title": "AnotherPayloadDto", - "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", - "schema": { - "$ref": "#/components/schemas/AnotherPayloadDto" - } - }, - "headers": { - "$ref": "#/components/schemas/HeadersNotDocumented" - }, - "bindings": { - "kafka": {} - } - } - }, "bindings": { - "kafka": {} + "kafka": { } } }, "example-topic": { - "address": "example-topic", - "messages": { - "example-topic_publish_process.message": { - "name": "io.github.stavshamir.springwolf.example.cloudstream.dtos.ExamplePayloadDto", - "title": "ExamplePayloadDto", - "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", - "schema": { - "$ref": "#/components/schemas/ExamplePayloadDto" - } - }, - "headers": { - "$ref": "#/components/schemas/HeadersNotDocumented" - }, - "bindings": { - "kafka": {} - } - } - }, "bindings": { - "kafka": {} + "kafka": { } } } }, - "operations": { - "another-topic_publish_consumerMethod": { - "action": "receive", - "channel": { - "$ref": "#/channels/another-topic" - }, - "description": "Auto-generated description", - "bindings": { - "kafka": {} - }, - "messages": [ - { - "$ref": "#/channels/another-topic/messages/another-topic_publish_consumerMethod.message" - } - ] - }, - "another-topic_subscribe_process": { - "action": "send", - "channel": { - "$ref": "#/channels/another-topic" - }, - "description": "Auto-generated description", - "bindings": { - "kafka": {} - }, - "messages": [ - { - "$ref": "#/channels/another-topic/messages/another-topic_subscribe_process.message" - } - ] - }, - "example-topic_publish_process": { - "action": "receive", - "channel": { - "$ref": "#/channels/example-topic" - }, - "description": "Auto-generated description", - "bindings": { - "kafka": {} - }, - "messages": [ - { - "$ref": "#/channels/example-topic/messages/example-topic_publish_process.message" - } - ] - } - }, "components": { "schemas": { "AnotherPayloadDto": { @@ -200,9 +98,10 @@ }, "HeadersNotDocumented": { "type": "object", - "properties": {}, - "example": {} + "properties": { }, + "example": { } } } - } + }, + "operations": { } } \ No newline at end of file diff --git a/springwolf-examples/springwolf-jms-example/src/test/resources/asyncapi.json b/springwolf-examples/springwolf-jms-example/src/test/resources/asyncapi.json index 78cbb5266..35075dd87 100644 --- a/springwolf-examples/springwolf-jms-example/src/test/resources/asyncapi.json +++ b/springwolf-examples/springwolf-jms-example/src/test/resources/asyncapi.json @@ -12,138 +12,73 @@ "license": { "name": "Apache License 2.0" }, - "tags": [], "x-generator": "springwolf" }, "defaultContentType": "application/json", "servers": { "jms": { - "host": "activemq:61616", + "host": "tcp://localhost:61616", "protocol": "jms" } }, "channels": { "another-queue": { - "address": "another-queue", "messages": { - "another-queue_publish_receiveAnotherPayload.message": { - "name": "io.github.stavshamir.springwolf.example.jms.dtos.AnotherPayloadDto", - "title": "AnotherPayloadDto", - "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", - "schema": { - "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.jms.dtos.AnotherPayloadDto" - } - }, + "io.github.stavshamir.springwolf.example.jms.dtos.AnotherPayloadDto": { "headers": { "$ref": "#/components/schemas/HeadersNotDocumented" }, - "bindings": { - "jms": {} - } - }, - "another-queue_subscribe.message": { - "name": "io.github.stavshamir.springwolf.example.jms.dtos.AnotherPayloadDto", - "title": "AnotherPayloadDto", - "description": "Another payload model", "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", "schema": { "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.jms.dtos.AnotherPayloadDto" } }, - "headers": { - "$ref": "#/components/schemas/HeadersNotDocumented" - }, + "name": "io.github.stavshamir.springwolf.example.jms.dtos.AnotherPayloadDto", + "title": "AnotherPayloadDto", + "description": "Another payload model", "bindings": { - "jms": {} + "jms": { + "bindingVersion": "0.0.1" + } } } } }, "example-queue": { - "address": "example-queue", "messages": { - "example-queue_publish_receiveExamplePayload.message": { - "name": "io.github.stavshamir.springwolf.example.jms.dtos.ExamplePayloadDto", - "title": "ExamplePayloadDto", + "io.github.stavshamir.springwolf.example.jms.dtos.ExamplePayloadDto": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", "schema": { "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.jms.dtos.ExamplePayloadDto" } }, - "headers": { - "$ref": "#/components/schemas/HeadersNotDocumented" - }, + "name": "io.github.stavshamir.springwolf.example.jms.dtos.ExamplePayloadDto", + "title": "ExamplePayloadDto", "bindings": { - "jms": {} + "jms": { + "bindingVersion": "0.0.1" + } } } }, - "bindings": { - "jms": {} - } - } - }, - "operations": { - "another-queue_publish_receiveAnotherPayload": { - "action": "receive", - "channel": { - "$ref": "#/channels/another-queue" - }, - "description": "Auto-generated description", - "bindings": { - "jms": {} - }, - "messages": [ - { - "$ref": "#/channels/another-queue/messages/another-queue_publish_receiveAnotherPayload.message" - } - ] - }, - "another-queue_subscribe": { - "action": "send", - "channel": { - "$ref": "#/channels/another-queue" - }, - "description": "Custom, optional description defined in the AsyncPublisher annotation", "bindings": { "jms": { - "internal-field": "customValue", - "nested": { - "key": "nestedValue" - } + "bindingVersion": "0.0.1" } - }, - "messages": [ - { - "$ref": "#/channels/another-queue/messages/another-queue_subscribe.message" - } - ] - }, - "example-queue_publish_receiveExamplePayload": { - "action": "receive", - "channel": { - "$ref": "#/channels/example-queue" - }, - "description": "Auto-generated description", - "bindings": { - "jms": {} - }, - "messages": [ - { - "$ref": "#/channels/example-queue/messages/example-queue_publish_receiveExamplePayload.message" - } - ] + } } }, "components": { "schemas": { "HeadersNotDocumented": { "type": "object", - "properties": {}, - "example": {} + "properties": { }, + "example": { } }, "io.github.stavshamir.springwolf.example.jms.dtos.AnotherPayloadDto": { "required": [ @@ -207,5 +142,45 @@ } } } + }, + "operations": { + "another-queue": { + "action": "send", + "title": "another-queue_subscribe", + "description": "Custom, optional description defined in the AsyncPublisher annotation", + "bindings": { + "jms": { + "internal-field": "customValue", + "nested": { + "key": "nestedValue" + } + } + }, + "messages": [ + { + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.jms.dtos.AnotherPayloadDto" + } + ] + }, + "another-queue_publish_receiveAnotherPayload": { + "bindings": { + "jms": { } + }, + "messages": [ + { + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.jms.dtos.AnotherPayloadDto" + } + ] + }, + "example-queue_publish_receiveExamplePayload": { + "bindings": { + "jms": { } + }, + "messages": [ + { + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.jms.dtos.ExamplePayloadDto" + } + ] + } } } \ No newline at end of file diff --git a/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json b/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json index ba5f55984..19d6fc64e 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json +++ b/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json @@ -12,7 +12,6 @@ "license": { "name": "Apache License 2.0" }, - "tags": [], "x-generator": "springwolf" }, "defaultContentType": "application/json", @@ -24,20 +23,19 @@ }, "channels": { "another-topic": { - "address": "another-topic", "messages": { - "another-topic_publish_receiveAnotherPayloadBatched.message": { - "name": "io.github.stavshamir.springwolf.example.kafka.dtos.AnotherPayloadDto", - "title": "AnotherPayloadDto", + "io.github.stavshamir.springwolf.example.kafka.dtos.AnotherPayloadDto": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", "schema": { "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.kafka.dtos.AnotherPayloadDto" } }, - "headers": { - "$ref": "#/components/schemas/HeadersNotDocumented" - }, + "name": "io.github.stavshamir.springwolf.example.kafka.dtos.AnotherPayloadDto", + "title": "AnotherPayloadDto", "bindings": { "kafka": { "bindingVersion": "0.4.0" @@ -52,24 +50,19 @@ } }, "avro-topic": { - "publish": { - "operationId": "avro-topic_publish", - "description": "Requires a running kafka-schema-registry. See docker-compose.yml to start it", - "bindings": { - "kafka": { - "bindingVersion": "0.4.0" - } - }, - "message": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", - "name": "io.github.stavshamir.springwolf.example.kafka.dto.avro.ExamplePayloadAvroDto", - "title": "ExamplePayloadAvroDto", - "payload": { - "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.kafka.dto.avro.ExamplePayloadAvroDto" - }, + "messages": { + "io.github.stavshamir.springwolf.example.kafka.dto.avro.ExamplePayloadAvroDto": { "headers": { "$ref": "#/components/schemas/HeadersNotDocumented" }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.kafka.dto.avro.ExamplePayloadAvroDto" + } + }, + "name": "io.github.stavshamir.springwolf.example.kafka.dto.avro.ExamplePayloadAvroDto", + "title": "ExamplePayloadAvroDto", "bindings": { "kafka": { "bindingVersion": "0.4.0" @@ -79,20 +72,19 @@ } }, "example-topic": { - "address": "example-topic", "messages": { - "example-topic_publish_receiveExamplePayload.message": { - "name": "io.github.stavshamir.springwolf.example.kafka.dtos.ExamplePayloadDto", - "title": "ExamplePayloadDto", + "io.github.stavshamir.springwolf.example.kafka.dtos.ExamplePayloadDto": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", "schema": { "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.kafka.dtos.ExamplePayloadDto" } }, - "headers": { - "$ref": "#/components/schemas/HeadersNotDocumented" - }, + "name": "io.github.stavshamir.springwolf.example.kafka.dtos.ExamplePayloadDto", + "title": "ExamplePayloadDto", "bindings": { "kafka": { "bindingVersion": "0.4.0" @@ -107,88 +99,77 @@ } }, "multi-payload-topic": { - "address": "multi-payload-topic", "messages": { - "multi-payload-topic_publish.message.0": { - "name": "io.github.stavshamir.springwolf.example.kafka.dtos.AnotherPayloadDto", - "title": "AnotherPayloadDto", + "io.github.stavshamir.springwolf.example.kafka.dtos.AnotherPayloadDto": { + "headers": { + "$ref": "#/components/schemas/SpringKafkaDefaultHeaders-AnotherPayloadDto" + }, "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", "schema": { "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.kafka.dtos.AnotherPayloadDto" } }, - "headers": { - "$ref": "#/components/schemas/SpringKafkaDefaultHeaders-AnotherPayloadDto" - }, + "name": "io.github.stavshamir.springwolf.example.kafka.dtos.AnotherPayloadDto", + "title": "AnotherPayloadDto", "bindings": { "kafka": { "bindingVersion": "0.4.0" } } }, - "multi-payload-topic_publish.message.1": { - "name": "io.github.stavshamir.springwolf.example.kafka.dtos.ExamplePayloadDto", - "title": "ExamplePayloadDto", + "io.github.stavshamir.springwolf.example.kafka.dtos.ExamplePayloadDto": { + "headers": { + "$ref": "#/components/schemas/SpringKafkaDefaultHeaders-ExamplePayloadDto" + }, "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", "schema": { "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.kafka.dtos.ExamplePayloadDto" } }, - "headers": { - "$ref": "#/components/schemas/SpringKafkaDefaultHeaders-ExamplePayloadDto" - }, + "name": "io.github.stavshamir.springwolf.example.kafka.dtos.ExamplePayloadDto", + "title": "ExamplePayloadDto", "bindings": { "kafka": { "bindingVersion": "0.4.0" } } }, - "multi-payload-topic_publish.message.2": { - "name": "javax.money.MonetaryAmount", - "title": "MonetaryAmount", + "javax.money.MonetaryAmount": { + "headers": { + "$ref": "#/components/schemas/SpringKafkaDefaultHeaders-MonetaryAmount" + }, "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", "schema": { "$ref": "#/components/schemas/io.github.stavshamir.springwolf.addons.common_model_converters.converters.monetaryamount.MonetaryAmount" } }, - "headers": { - "$ref": "#/components/schemas/SpringKafkaDefaultHeaders-MonetaryAmount" - }, + "name": "javax.money.MonetaryAmount", + "title": "MonetaryAmount", "bindings": { "kafka": { - "key": { - "type": "string", - "description": "Kafka Consumer Message Key", - "example": "example-key" - }, "bindingVersion": "0.4.0" } } } } }, - "protobuf-topic": { - "publish": { - "operationId": "protobuf-topic_publish_receiveExampleProtobufPayload", - "description": "Auto-generated description", - "bindings": { - "kafka": { - "bindingVersion": "0.4.0" - } - }, - "message": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", - "name": "io.github.stavshamir.springwolf.example.kafka.dto.proto.ExamplePayloadProtobufDto$Message", - "title": "Message", - "payload": { - "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.kafka.dto.proto.ExamplePayloadProtobufDto$Message" - }, + "primitive-topic": { + "messages": { + "java.lang.String": { "headers": { "$ref": "#/components/schemas/HeadersNotDocumented" }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "$ref": "#/components/schemas/String" + } + }, + "name": "java.lang.String", + "title": "String", "bindings": { "kafka": { "bindingVersion": "0.4.0" @@ -202,68 +183,20 @@ } } }, - "string-topic": { - "publish": { - "operationId": "string-topic_publish", - "description": "Final classes (like String) can be documented using an envelope class and the @AsyncApiPayload annotation.", - "bindings": { - "kafka": { - "bindingVersion": "0.4.0" - } - }, - "message": { - "oneOf": [ - { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", - "name": "io.github.stavshamir.springwolf.example.kafka.consumers.StringConsumer$StringEnvelope", - "title": "StringEnvelope", - "payload": { - "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.kafka.consumers.StringConsumer$StringEnvelope" - }, - "headers": { - "$ref": "#/components/schemas/HeadersNotDocumented" - }, - "bindings": { - "kafka": { - "bindingVersion": "0.4.0" - } - } - }, - { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", - "name": "java.lang.String", - "title": "String", - "payload": { - "$ref": "#/components/schemas/String" - }, - "headers": { - "$ref": "#/components/schemas/HeadersNotDocumented" - }, - "bindings": { - "kafka": { - "bindingVersion": "0.4.0" - } - } - } - ] - } - } - }, - "primitive-topic": { - "address": "primitive-topic", + "protobuf-topic": { "messages": { - "primitive-topic_publish_receivePrimitivePayload.message": { - "name": "java.lang.String", - "title": "String", + "io.github.stavshamir.springwolf.example.kafka.dto.proto.ExamplePayloadProtobufDto$Message": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", "schema": { - "$ref": "#/components/schemas/String" + "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.kafka.dto.proto.ExamplePayloadProtobufDto$Message" } }, - "headers": { - "$ref": "#/components/schemas/HeadersNotDocumented" - }, + "name": "io.github.stavshamir.springwolf.example.kafka.dto.proto.ExamplePayloadProtobufDto$Message", + "title": "Message", "bindings": { "kafka": { "bindingVersion": "0.4.0" @@ -277,151 +210,68 @@ } } }, - "topic-defined-via-asyncPublisher-annotation": { - "address": "topic-defined-via-asyncPublisher-annotation", + "string-topic": { "messages": { - "topic-defined-via-asyncPublisher-annotation_subscribe.message": { - "name": "io.github.stavshamir.springwolf.example.kafka.dtos.NestedPayloadDto", - "title": "NestedPayloadDto", - "description": "Payload model with nested complex types", + "io.github.stavshamir.springwolf.example.kafka.consumers.StringConsumer$StringEnvelope": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", "schema": { - "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.kafka.dtos.NestedPayloadDto" + "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.kafka.consumers.StringConsumer$StringEnvelope" } }, + "name": "io.github.stavshamir.springwolf.example.kafka.consumers.StringConsumer$StringEnvelope", + "title": "StringEnvelope", + "bindings": { + "kafka": { + "bindingVersion": "0.4.0" + } + } + }, + "java.lang.String": { "headers": { - "$ref": "#/components/schemas/SpringDefaultHeaderAndCloudEvent" + "$ref": "#/components/schemas/HeadersNotDocumented" }, + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "$ref": "#/components/schemas/String" + } + }, + "name": "java.lang.String", + "title": "String", "bindings": { "kafka": { - "key": { - "type": "string", - "description": "Kafka Producer Message Key", - "example": "example-key" - }, "bindingVersion": "0.4.0" } } } } - } - }, - "operations": { - "another-topic_publish_receiveAnotherPayloadBatched": { - "action": "receive", - "channel": { - "$ref": "#/channels/another-topic" - }, - "description": "Auto-generated description", - "bindings": { - "kafka": { - "groupId": { - "type": "string", - "enum": [ - "example-group-id" - ] - }, - "bindingVersion": "0.4.0" - } - }, - "messages": [ - { - "$ref": "#/channels/another-topic/messages/another-topic_publish_receiveAnotherPayloadBatched.message" - } - ] - }, - "example-topic_publish_receiveExamplePayload": { - "action": "receive", - "channel": { - "$ref": "#/channels/example-topic" - }, - "description": "Auto-generated description", - "bindings": { - "kafka": { - "bindingVersion": "0.4.0" - } - }, - "messages": [ - { - "$ref": "#/channels/example-topic/messages/example-topic_publish_receiveExamplePayload.message" - } - ] }, - "multi-payload-topic_publish": { - "action": "receive", - "channel": { - "$ref": "#/channels/multi-payload-topic" - }, - "description": "Override description in the AsyncListener annotation with servers at kafka:29092", - "bindings": { - "kafka": { - "groupId": { - "type": "string", - "enum": [ - "foo-groupId" - ] - }, - "clientId": { - "type": "string", - "enum": [ - "foo-clientId" - ] + "topic-defined-via-asyncPublisher-annotation": { + "messages": { + "io.github.stavshamir.springwolf.example.kafka.dtos.NestedPayloadDto": { + "headers": { + "$ref": "#/components/schemas/SpringDefaultHeaderAndCloudEvent" }, - "bindingVersion": "0.4.0" - } - }, - "messages": [ - { - "$ref": "#/channels/multi-payload-topic/messages/multi-payload-topic_publish.message.0" - }, - { - "$ref": "#/channels/multi-payload-topic/messages/multi-payload-topic_publish.message.1" - }, - { - "$ref": "#/channels/multi-payload-topic/messages/multi-payload-topic_publish.message.2" - } - ] - }, - "primitive-topic_publish_receivePrimitivePayload": { - "action": "receive", - "channel": { - "$ref": "#/channels/primitive-topic" - }, - "description": "Auto-generated description", - "bindings": { - "kafka": { - "bindingVersion": "0.4.0" - } - }, - "messages": [ - { - "$ref": "#/channels/primitive-topic/messages/primitive-topic_publish_receivePrimitivePayload.message" - } - ] - }, - "topic-defined-via-asyncPublisher-annotation_subscribe": { - "action": "send", - "channel": { - "$ref": "#/channels/topic-defined-via-asyncPublisher-annotation" - }, - "description": "Custom, optional description defined in the AsyncPublisher annotation", - "bindings": { - "kafka": { - "clientId": { - "type": "string", - "enum": [ - "foo-clientId" - ] + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.kafka.dtos.NestedPayloadDto" + } }, - "bindingVersion": "0.4.0" - } - }, - "messages": [ - { - "$ref": "#/channels/topic-defined-via-asyncPublisher-annotation/messages/topic-defined-via-asyncPublisher-annotation_subscribe.message" + "name": "io.github.stavshamir.springwolf.example.kafka.dtos.NestedPayloadDto", + "title": "NestedPayloadDto", + "description": "Payload model with nested complex types", + "bindings": { + "kafka": { + "bindingVersion": "0.4.0" + } + } } - ] + } } }, "components": { @@ -1023,5 +873,170 @@ } } } + }, + "operations": { + "another-topic_publish_receiveAnotherPayloadBatched": { + "bindings": { + "kafka": { + "groupId": { + "type": "string", + "enum": [ + "example-group-id" + ] + }, + "bindingVersion": "0.4.0" + } + }, + "messages": [ + { + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.kafka.dtos.AnotherPayloadDto" + } + ] + }, + "avro-topic": { + "action": "receive", + "title": "avro-topic_publish", + "description": "Requires a running kafka-schema-registry. See docker-compose.yml to start it", + "bindings": { + "kafka": { + "bindingVersion": "0.4.0" + } + }, + "messages": [ + { + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.kafka.dto.avro.ExamplePayloadAvroDto" + } + ] + }, + "avro-topic_publish_receiveExampleAvroPayload": { + "bindings": { + "kafka": { + "bindingVersion": "0.4.0" + } + }, + "messages": [ + { + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.kafka.dto.avro.ExamplePayloadAvroDto" + } + ] + }, + "example-topic_publish_receiveExamplePayload": { + "bindings": { + "kafka": { + "bindingVersion": "0.4.0" + } + }, + "messages": [ + { + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.kafka.dtos.ExamplePayloadDto" + } + ] + }, + "multi-payload-topic": { + "action": "receive", + "title": "multi-payload-topic_publish", + "description": "Override description in the AsyncListener annotation with servers at localhost:50082", + "bindings": { + "kafka": { + "groupId": { + "type": "string", + "enum": [ + "foo-groupId" + ] + }, + "clientId": { + "type": "string", + "enum": [ + "foo-clientId" + ] + }, + "bindingVersion": "0.4.0" + } + }, + "messages": [ + { + "$ref": "#/components/messages/javax.money.MonetaryAmount" + } + ] + }, + "multi-payload-topic_publish_ExampleClassLevelKafkaListener": { + "bindings": { + "kafka": { + "bindingVersion": "0.4.0" + } + } + }, + "primitive-topic_publish_receivePrimitivePayload": { + "bindings": { + "kafka": { + "bindingVersion": "0.4.0" + } + }, + "messages": [ + { + "$ref": "#/components/messages/java.lang.String" + } + ] + }, + "protobuf-topic_publish_receiveExampleProtobufPayload": { + "bindings": { + "kafka": { + "bindingVersion": "0.4.0" + } + }, + "messages": [ + { + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.kafka.dto.proto.ExamplePayloadProtobufDto$Message" + } + ] + }, + "string-topic": { + "action": "receive", + "title": "string-topic_publish", + "description": "Final classes (like String) can be documented using an envelope class and the @AsyncApiPayload annotation.", + "bindings": { + "kafka": { + "bindingVersion": "0.4.0" + } + }, + "messages": [ + { + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.kafka.consumers.StringConsumer$StringEnvelope" + } + ] + }, + "string-topic_publish_receiveStringPayload": { + "bindings": { + "kafka": { + "bindingVersion": "0.4.0" + } + }, + "messages": [ + { + "$ref": "#/components/messages/java.lang.String" + } + ] + }, + "topic-defined-via-asyncPublisher-annotation": { + "action": "send", + "title": "topic-defined-via-asyncPublisher-annotation_subscribe", + "description": "Custom, optional description defined in the AsyncPublisher annotation", + "bindings": { + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "foo-clientId" + ] + }, + "bindingVersion": "0.4.0" + } + }, + "messages": [ + { + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.kafka.dtos.NestedPayloadDto" + } + ] + } } } diff --git a/springwolf-examples/springwolf-sns-example/src/test/resources/asyncapi.json b/springwolf-examples/springwolf-sns-example/src/test/resources/asyncapi.json index 0541a6823..08d3b9193 100644 --- a/springwolf-examples/springwolf-sns-example/src/test/resources/asyncapi.json +++ b/springwolf-examples/springwolf-sns-example/src/test/resources/asyncapi.json @@ -17,68 +17,49 @@ "defaultContentType": "application/json", "servers": { "sns": { - "host": "localhost:4566", + "host": "http://localhost:4566", "protocol": "sns" } }, "channels": { "another-topic": { - "address": "another-topic", "messages": { - "another-topic_publish.message": { - "name": "io.github.stavshamir.springwolf.example.sns.dtos.AnotherPayloadDto", - "title": "AnotherPayloadDto", - "description": "Another payload model", - "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", - "schema": { - "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.sns.dtos.AnotherPayloadDto" - } - }, + "io.github.stavshamir.springwolf.example.sns.dtos.AnotherPayloadDto": { "headers": { "$ref": "#/components/schemas/HeadersNotDocumented" }, - "bindings": { - "sns": {} - } - }, - "another-topic_subscribe.message": { - "name": "io.github.stavshamir.springwolf.example.sns.dtos.AnotherPayloadDto", - "title": "AnotherPayloadDto", - "description": "Another payload model", "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", "schema": { "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.sns.dtos.AnotherPayloadDto" } }, - "headers": { - "$ref": "#/components/schemas/HeadersNotDocumented" - }, + "name": "io.github.stavshamir.springwolf.example.sns.dtos.AnotherPayloadDto", + "title": "AnotherPayloadDto", + "description": "Another payload model", "bindings": { - "sns": {} + "sns": { } } } } }, "example-topic": { - "address": "example-topic", "messages": { - "example-topic_publish.message": { - "name": "io.github.stavshamir.springwolf.example.sns.dtos.ExamplePayloadDto", - "title": "ExamplePayloadDto", - "description": "Example payload model", + "io.github.stavshamir.springwolf.example.sns.dtos.ExamplePayloadDto": { + "headers": { + "$ref": "#/components/schemas/HeadersNotDocumented" + }, "payload": { - "schemaFormat": "application/vnd.oai.openapi+json;version=3.0.0", + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", "schema": { "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.sns.dtos.ExamplePayloadDto" } }, - "headers": { - "$ref": "#/components/schemas/HeadersNotDocumented" - }, + "name": "io.github.stavshamir.springwolf.example.sns.dtos.ExamplePayloadDto", + "title": "ExamplePayloadDto", + "description": "Example payload model", "bindings": { - "sns": {} + "sns": { } } } } @@ -88,8 +69,8 @@ "schemas": { "HeadersNotDocumented": { "type": "object", - "properties": {}, - "example": {}, + "properties": { }, + "example": { }, "x-json-schema": { "$schema": "https://json-schema.org/draft-04/schema#", "name": "HeadersNotDocumented", @@ -241,78 +222,33 @@ } }, "operations": { - "another-topic_publish": { + "another-topic": { "action": "receive", - "channel": { - "$ref": "#/channels/another-topic" - }, + "title": "another-topic_publish", "description": "Auto-generated description", "bindings": { "sns": { - "consumers": [ - { - "protocol": "sqs", - "endpoint": { - "name": "myQueue" - }, - "rawMessageDelivery": false - } - ] - } - }, - "messages": [ - { - "$ref": "#/channels/another-topic/messages/another-topic_publish.message" - } - ] - }, - "another-topic_subscribe": { - "action": "send", - "channel": { - "$ref": "#/channels/another-topic" - }, - "description": "Custom, optional description defined in the AsyncPublisher annotation", - "bindings": { - "sns": { - "consumers": [ - { - "protocol": "sqs", - "endpoint": { - "name": "myQueue" - }, - "rawMessageDelivery": false - } - ] + "bindingVersion": "0.1.0" } }, "messages": [ { - "$ref": "#/channels/another-topic/messages/another-topic_subscribe.message" + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.sns.dtos.AnotherPayloadDto" } ] }, - "example-topic_publish": { + "example-topic": { "action": "receive", - "channel": { - "$ref": "#/channels/example-topic" - }, + "title": "example-topic_publish", "description": "Auto-generated description", "bindings": { "sns": { - "consumers": [ - { - "protocol": "sqs", - "endpoint": { - "name": "myQueue" - }, - "rawMessageDelivery": false - } - ] + "bindingVersion": "0.1.0" } }, "messages": [ { - "$ref": "#/channels/example-topic/messages/example-topic_publish.message" + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.sns.dtos.ExamplePayloadDto" } ] } diff --git a/springwolf-examples/springwolf-sqs-example/src/test/resources/asyncapi.json b/springwolf-examples/springwolf-sqs-example/src/test/resources/asyncapi.json index 8633462ba..1185bd2e9 100644 --- a/springwolf-examples/springwolf-sqs-example/src/test/resources/asyncapi.json +++ b/springwolf-examples/springwolf-sqs-example/src/test/resources/asyncapi.json @@ -24,7 +24,7 @@ "channels": { "another-queue": { "messages": { - "another-queue_publish_receiveAnotherPayload.message": { + "io.github.stavshamir.springwolf.example.sqs.dtos.AnotherPayloadDto": { "headers": { "$ref": "#/components/schemas/HeadersNotDocumented" }, @@ -36,32 +36,16 @@ }, "name": "io.github.stavshamir.springwolf.example.sqs.dtos.AnotherPayloadDto", "title": "AnotherPayloadDto", - "bindings": { - "sqs": {} - } - }, - "another-queue_subscribe.message": { "description": "Another payload model", - "headers": { - "$ref": "#/components/schemas/HeadersNotDocumented" - }, - "payload": { - "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", - "schema": { - "$ref": "#/components/schemas/io.github.stavshamir.springwolf.example.sqs.dtos.AnotherPayloadDto" - } - }, - "name": "io.github.stavshamir.springwolf.example.sqs.dtos.AnotherPayloadDto", - "title": "AnotherPayloadDto", "bindings": { - "sqs": {} + "sqs": { } } } } }, "example-queue": { "messages": { - "example-queue_publish_receiveExamplePayload.message": { + "io.github.stavshamir.springwolf.example.sqs.dtos.ExamplePayloadDto": { "headers": { "$ref": "#/components/schemas/HeadersNotDocumented" }, @@ -74,16 +58,13 @@ "name": "io.github.stavshamir.springwolf.example.sqs.dtos.ExamplePayloadDto", "title": "ExamplePayloadDto", "bindings": { - "sqs": {} + "sqs": { } } } }, "bindings": { "sqs": { - "queue": { - "name": "example-queue", - "fifoQueue": true, - } + "bindingVersion": "0.2.0" } } } @@ -92,8 +73,8 @@ "schemas": { "HeadersNotDocumented": { "type": "object", - "properties": {}, - "example": {} + "properties": { }, + "example": { } }, "io.github.stavshamir.springwolf.example.sqs.dtos.AnotherPayloadDto": { "required": [ @@ -159,63 +140,45 @@ } }, "operations": { - "another-queue_publish_receiveAnotherPayload": { - "action": "receive", - "channel": { - "$ref": "#/channels/another-queue" - }, - "description": "Auto-generated description", + "another-queue": { + "action": "send", + "title": "another-queue_subscribe", + "description": "Custom, optional description defined in the AsyncPublisher annotation", "bindings": { "sqs": { - "queues": [{ - "name": "another-queue", - "fifoQueue": true, - }] + "internal-field": "customValue", + "nested": { + "key": "nestedValue" + } } }, "messages": [ { - "$ref": "#/channels/another-queue/messages/another-queue_publish_receiveAnotherPayload.message" + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.sqs.dtos.AnotherPayloadDto" } ] }, - "another-queue_subscribe": { - "action": "send", - "channel": { - "$ref": "#/channels/another-queue" - }, - "description": "Custom, optional description defined in the AsyncPublisher annotation", + "another-queue_publish_receiveAnotherPayload": { "bindings": { "sqs": { - "queues": [{ - "name": "another-queue", - "fifoQueue": true, - }] + "bindingVersion": "0.2.0" } }, "messages": [ { - "$ref": "#/channels/another-queue/messages/another-queue_subscribe.message" + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.sqs.dtos.AnotherPayloadDto" } ] }, "example-queue_publish_receiveExamplePayload": { - "action": "receive", - "channel": { - "$ref": "#/channels/example-queue" - }, - "description": "Auto-generated description", "bindings": { "sqs": { - "queues": [{ - "name": "another-queue", - "fifoQueue": true, - }] + "bindingVersion": "0.2.0" } }, "messages": [ { - "$ref": "#/channels/example-queue/messages/example-queue_publish_receiveExamplePayload.message" + "$ref": "#/components/messages/io.github.stavshamir.springwolf.example.sqs.dtos.ExamplePayloadDto" } ] } From ffacab7c6caf6380085e7c7096a97e333fbfdf28 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Sat, 13 Jan 2024 16:42:12 +0100 Subject: [PATCH 5/6] test(kafka): update asyncapi model --- .../src/test/resources/asyncapi.json | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json b/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json index 19d6fc64e..c75d48144 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json +++ b/springwolf-examples/springwolf-kafka-example/src/test/resources/asyncapi.json @@ -876,6 +876,10 @@ }, "operations": { "another-topic_publish_receiveAnotherPayloadBatched": { + "action": "receive", + "channel": { + "$ref": "#/channels/another-topic" + }, "bindings": { "kafka": { "groupId": { @@ -895,6 +899,9 @@ }, "avro-topic": { "action": "receive", + "channel": { + "$ref": "#/channels/avro-topic" + }, "title": "avro-topic_publish", "description": "Requires a running kafka-schema-registry. See docker-compose.yml to start it", "bindings": { @@ -909,6 +916,10 @@ ] }, "avro-topic_publish_receiveExampleAvroPayload": { + "action": "receive", + "channel": { + "$ref": "#/channels/avro-topic" + }, "bindings": { "kafka": { "bindingVersion": "0.4.0" @@ -921,6 +932,10 @@ ] }, "example-topic_publish_receiveExamplePayload": { + "action": "receive", + "channel": { + "$ref": "#/channels/example-topic" + }, "bindings": { "kafka": { "bindingVersion": "0.4.0" @@ -934,8 +949,11 @@ }, "multi-payload-topic": { "action": "receive", + "channel": { + "$ref": "#/channels/multi-payload-topic" + }, "title": "multi-payload-topic_publish", - "description": "Override description in the AsyncListener annotation with servers at localhost:50082", + "description": "Override description in the AsyncListener annotation with servers at localhost:51006", "bindings": { "kafka": { "groupId": { @@ -960,6 +978,10 @@ ] }, "multi-payload-topic_publish_ExampleClassLevelKafkaListener": { + "action": "receive", + "channel": { + "$ref": "#/channels/multi-payload-topic" + }, "bindings": { "kafka": { "bindingVersion": "0.4.0" @@ -967,6 +989,10 @@ } }, "primitive-topic_publish_receivePrimitivePayload": { + "action": "receive", + "channel": { + "$ref": "#/channels/primitive-topic" + }, "bindings": { "kafka": { "bindingVersion": "0.4.0" @@ -979,6 +1005,10 @@ ] }, "protobuf-topic_publish_receiveExampleProtobufPayload": { + "action": "receive", + "channel": { + "$ref": "#/channels/protobuf-topic" + }, "bindings": { "kafka": { "bindingVersion": "0.4.0" @@ -992,6 +1022,9 @@ }, "string-topic": { "action": "receive", + "channel": { + "$ref": "#/channels/string-topic" + }, "title": "string-topic_publish", "description": "Final classes (like String) can be documented using an envelope class and the @AsyncApiPayload annotation.", "bindings": { @@ -1006,6 +1039,10 @@ ] }, "string-topic_publish_receiveStringPayload": { + "action": "receive", + "channel": { + "$ref": "#/channels/string-topic" + }, "bindings": { "kafka": { "bindingVersion": "0.4.0" @@ -1019,6 +1056,9 @@ }, "topic-defined-via-asyncPublisher-annotation": { "action": "send", + "channel": { + "$ref": "#/channels/topic-defined-via-asyncPublisher-annotation" + }, "title": "topic-defined-via-asyncPublisher-annotation_subscribe", "description": "Custom, optional description defined in the AsyncPublisher annotation", "bindings": { From 9c72c76f0fbaf7f3d671055d1eecdb543f08be70 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Sat, 13 Jan 2024 16:43:54 +0100 Subject: [PATCH 6/6] feat(ui): move asyncapi v3 changes --- springwolf-ui/src/app/app.component.css | 2 +- .../channel-main/channel-main.component.html | 22 +++- .../channel-main/channel-main.component.ts | 9 +- .../channels/channels.component.css | 4 +- .../channels/channels.component.html | 8 +- .../app/components/info/info.component.html | 6 +- .../components/servers/servers.component.html | 17 ++- springwolf-ui/src/app/models/channel.model.ts | 28 +---- springwolf-ui/src/app/models/message.model.ts | 20 ++++ .../src/app/models/operation.model.ts | 11 ++ .../asyncapi/asyncapi-mapper.service.ts | 107 ++++++++++-------- .../service/asyncapi/models/asyncapi.model.ts | 4 - .../service/asyncapi/models/channels.model.ts | 1 - .../service/asyncapi/models/info.models.ts | 8 +- .../service/asyncapi/models/message.model.ts | 7 +- .../asyncapi/models/operations.model.ts | 17 ++- .../service/asyncapi/models/schema.model.ts | 6 +- 17 files changed, 166 insertions(+), 111 deletions(-) create mode 100644 springwolf-ui/src/app/models/message.model.ts create mode 100644 springwolf-ui/src/app/models/operation.model.ts diff --git a/springwolf-ui/src/app/app.component.css b/springwolf-ui/src/app/app.component.css index 7294c4b3c..45f9002fd 100644 --- a/springwolf-ui/src/app/app.component.css +++ b/springwolf-ui/src/app/app.component.css @@ -7,5 +7,5 @@ main { margin: 0 64px; - padding: 64px 0; + padding-bottom: 32px; } diff --git a/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.html b/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.html index 01b1b509f..56484a9dd 100644 --- a/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.html +++ b/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.html @@ -9,7 +9,10 @@

{{ operation.message.description }}

Message Binding

@@ -19,7 +22,7 @@

Message Binding

[rows]="messageBindingExampleTextAreaLineCount" [value]=" createMessageBindingExample( - operation.message.bindings.get(protocolName) + operation.message.bindings.get(operation.protocol) )?.value " (keyup)=" @@ -74,7 +77,7 @@

Message

headersTextArea.value = headersExample?.value; headersTextAreaLineCount = headersExample?.lineCount || 0; bindingTextArea.value = createMessageBindingExample( - operation.message.bindings.get(protocolName) + operation.message.bindings.get(operation.protocol) )?.value; messageBindingExampleTextAreaLineCount = messageBindingExample?.lineCount || 0 @@ -114,10 +117,19 @@

- +
+ +
- +
+ +
diff --git a/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.ts b/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.ts index 76247f392..ac4a8d00b 100644 --- a/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.ts +++ b/springwolf-ui/src/app/components/channels/channel-main/channel-main.component.ts @@ -5,7 +5,7 @@ import { Example } from "src/app/models/example.model"; import { Schema } from "src/app/models/schema.model"; import { PublisherService } from "src/app/service/publisher.service"; import { MatSnackBar } from "@angular/material/snack-bar"; -import { Operation } from "src/app/models/channel.model"; +import { Operation } from "src/app/models/operation.model"; import { Binding } from "src/app/models/bindings.model"; import { STATUS } from "angular-in-memory-web-api"; @@ -28,7 +28,6 @@ export class ChannelMainComponent implements OnInit { headersSchemaIdentifier: string; headersExample: Example; headersTextAreaLineCount: number; - protocolName: string; messageBindingExample?: Example; messageBindingExampleTextAreaLineCount: number; @@ -59,8 +58,6 @@ export class ChannelMainComponent implements OnInit { this.messageBindingExampleTextAreaLineCount = this.messageBindingExample?.lineCount || 0; }); - - this.protocolName = Object.keys(this.operation.bindings)[0]; } isEmptyObject(object?: any): boolean { @@ -127,7 +124,7 @@ export class ChannelMainComponent implements OnInit { this.publisherService .publish( - this.protocolName, + this.operation.protocol, this.channelName, example, payloadType, @@ -158,7 +155,7 @@ export class ChannelMainComponent implements OnInit { private handlePublishError(err: { status?: number }) { let msg = "Publish failed"; if (err?.status === STATUS.NOT_FOUND) { - msg += ": no publisher was provided for " + this.protocolName; + msg += ": no publisher was provided for " + this.operation.protocol; } return this.snackBar.open(msg, "ERROR", { diff --git a/springwolf-ui/src/app/components/channels/channels.component.css b/springwolf-ui/src/app/components/channels/channels.component.css index a369a8039..2b614bf46 100644 --- a/springwolf-ui/src/app/components/channels/channels.component.css +++ b/springwolf-ui/src/app/components/channels/channels.component.css @@ -7,11 +7,11 @@ display: inline-block; } -.subscribe-badge { +.send-badge { background-color: #ffd580; } -.publish-badge { +.receive-badge { background-color: #9bd279; } diff --git a/springwolf-ui/src/app/components/channels/channels.component.html b/springwolf-ui/src/app/components/channels/channels.component.html index 1f25059fc..49844fcc5 100644 --- a/springwolf-ui/src/app/components/channels/channels.component.html +++ b/springwolf-ui/src/app/components/channels/channels.component.html @@ -16,14 +16,14 @@

Channels

- {{ channel.operation.operation }} + {{ channel.operation.operationType }}

{{ info?.title }}

- API VERSION {{ info?.version }} + API version {{ info?.version || "not specified" }} - - Download AsyncAPI JSON file + Download AsyncAPI file

diff --git a/springwolf-ui/src/app/components/servers/servers.component.html b/springwolf-ui/src/app/components/servers/servers.component.html index 45615dc6d..b69790125 100644 --- a/springwolf-ui/src/app/components/servers/servers.component.html +++ b/springwolf-ui/src/app/components/servers/servers.component.html @@ -5,6 +5,21 @@

Servers

{{ server.key }} - {{ server.value.url }} + + + + + + + + + + + +
Host: + {{ server.value.host }} +
Protocol: + {{ server.value.protocol }} +
diff --git a/springwolf-ui/src/app/models/channel.model.ts b/springwolf-ui/src/app/models/channel.model.ts index b7d72d2a9..1f9e9665f 100644 --- a/springwolf-ui/src/app/models/channel.model.ts +++ b/springwolf-ui/src/app/models/channel.model.ts @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: Apache-2.0 */ -import { Binding, Bindings } from "./bindings.model"; +import { Operation } from "./operation.model"; export const CHANNEL_ANCHOR_PREFIX = "#channel-"; export interface ChannelOperation { @@ -8,29 +8,3 @@ export interface ChannelOperation { description?: string; operation: Operation; } - -export type OperationType = "receive" | "send"; -export interface Operation { - message: Message; - bindings?: Bindings; - protocol: string; - operationType: OperationType; -} - -export interface Message { - name: string; - title: string; - description?: string; - payload: { - name: string; - title: string; - anchorUrl: string; - }; - headers: { - name: string; - title: string; - anchorUrl: string; - }; - bindings?: Map; - rawBindings?: { [protocol: string]: object }; -} diff --git a/springwolf-ui/src/app/models/message.model.ts b/springwolf-ui/src/app/models/message.model.ts new file mode 100644 index 000000000..b12c9d8a7 --- /dev/null +++ b/springwolf-ui/src/app/models/message.model.ts @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +import { Binding } from "./bindings.model"; + +export interface Message { + name: string; + title: string; + description?: string; + payload: { + name: string; + title: string; + anchorUrl: string; + }; + headers: { + name: string; + title: string; + anchorUrl: string; + }; + bindings?: Map; + rawBindings?: { [protocol: string]: object }; +} diff --git a/springwolf-ui/src/app/models/operation.model.ts b/springwolf-ui/src/app/models/operation.model.ts new file mode 100644 index 000000000..a15907543 --- /dev/null +++ b/springwolf-ui/src/app/models/operation.model.ts @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +import { Message } from "./message.model"; +import { Bindings } from "./bindings.model"; + +export type OperationType = "receive" | "send"; +export interface Operation { + message: Message; + bindings?: Bindings; + protocol?: string; + operationType: OperationType; +} diff --git a/springwolf-ui/src/app/service/asyncapi/asyncapi-mapper.service.ts b/springwolf-ui/src/app/service/asyncapi/asyncapi-mapper.service.ts index 2bc155d75..205890ff2 100644 --- a/springwolf-ui/src/app/service/asyncapi/asyncapi-mapper.service.ts +++ b/springwolf-ui/src/app/service/asyncapi/asyncapi-mapper.service.ts @@ -4,22 +4,21 @@ import { Server } from "../../models/server.model"; import { ChannelOperation, CHANNEL_ANCHOR_PREFIX, - Message, - Operation, - OperationType, } from "../../models/channel.model"; +import { Operation, OperationType } from "src/app/models/operation.model"; +import { Message } from "src/app/models/message.model"; import { Schema } from "../../models/schema.model"; import { Injectable } from "@angular/core"; import { Example } from "../../models/example.model"; import { Info } from "../../models/info.model"; -import { - ServerAsyncApi, - ServerAsyncApiChannelMessage, -} from "./models/asyncapi.model"; -import { ServerAsyncApiMessage } from "./models/message.model"; +import { ServerAsyncApi } from "./models/asyncapi.model"; import { ServerAsyncApiSchema } from "./models/schema.model"; import { ServerBinding, ServerBindings } from "./models/bindings.model"; -import { ServerOperations } from "./models/operations.model"; +import { + ServerOperationAction, + ServerOperationMessage, + ServerOperations, +} from "./models/operations.model"; import { ServerServers } from "./models/servers.model"; import { ServerChannel, ServerChannels } from "./models/channels.model"; import { Binding, Bindings } from "src/app/models/bindings.model"; @@ -77,27 +76,31 @@ export class AsyncApiMapperService { ): ChannelOperation[] { const s = new Array(); for (let operationsKey in operations) { - const operation = operations[operationsKey]; - const channelName = this.resolveRef(operation.channel.$ref); + this.parsingErrorBoundary("operation " + operationsKey, () => { + const operation = operations[operationsKey]; + const channelName = this.resolveRef(operation.channel.$ref); - const messages: Message[] = this.mapServerAsyncApiMessages( - operation.messages - ); - messages.forEach((message) => { - const channelOperation = this.parsingErrorBoundary( - "channel with name " + channelName, - () => - this.mapChannel( - channelName, - channels[channelName], - message, - operation.action - ) + const messages: Message[] = this.mapServerAsyncApiMessages( + channelName, + channels[channelName], + operation.messages ); + messages.forEach((message) => { + const channelOperation = this.parsingErrorBoundary( + "channel with name " + channelName, + () => + this.mapChannel( + channelName, + channels[channelName], + message, + operation.action + ) + ); - if (channelOperation != undefined) { - s.push(channelOperation); - } + if (channelOperation != undefined) { + s.push(channelOperation); + } + }); }); } return s; @@ -107,7 +110,7 @@ export class AsyncApiMapperService { channelName: string, channel: ServerChannel, message: Message, - operationType: ServerOperations["action"] + operationType: ServerOperationAction ): ChannelOperation { if ( channel.bindings == undefined || @@ -140,38 +143,41 @@ export class AsyncApiMapperService { } private mapServerAsyncApiMessages( - messages: ServerAsyncApiMessage[] + channelName: string, + channel: ServerChannel, + messages: ServerOperationMessage[] ): Message[] { return messages - .map((v) => { - const message = this.parsingErrorBoundary( - "message with name " + v.name, + .map((operationMessage) => { + return this.parsingErrorBoundary( + "message of channel " + channelName, () => { + const messageKey = this.resolveRef(operationMessage.$ref); + const message = channel.messages[messageKey]; + return { - name: v.name, - title: v.title, - description: v.description, + name: message.name, + title: message.title, + description: message.description, payload: { - name: v.payload.$ref, - title: this.resolveRef(v.payload.$ref), + name: message.payload.schema.$ref, + title: this.resolveRef(message.payload.schema.$ref), anchorUrl: AsyncApiMapperService.BASE_URL + - this.resolveRef(v.payload.$ref), + this.resolveRef(message.payload.schema.$ref), }, headers: { - name: v.headers.$ref, - title: v.headers.$ref?.split("/")?.pop(), + name: message.headers.$ref, + title: message.headers.$ref?.split("/")?.pop(), anchorUrl: AsyncApiMapperService.BASE_URL + - this.resolveRef(v.headers.$ref), + this.resolveRef(message.headers.$ref), }, - bindings: this.mapServerAsyncApiMessageBindings(v.bindings), - rawBindings: v.bindings, + bindings: this.mapServerAsyncApiMessageBindings(message.bindings), + rawBindings: message.bindings, }; } ); - - return message; }) .filter((el) => el != undefined); } @@ -209,7 +215,7 @@ export class AsyncApiMapperService { } private mapOperation( - operationType: ServerOperations["action"], + operationType: ServerOperationAction, message: Message, bindings?: Bindings ): Operation { @@ -221,8 +227,13 @@ export class AsyncApiMapperService { }; } - private getProtocol(bindings?: { [protocol: string]: object }): string { - return Object.keys(bindings)[0]; + private getProtocol(bindings?: { + [protocol: string]: object; + }): string | undefined { + if (bindings !== undefined) { + return Object.keys(bindings)[0]; + } + return undefined; } private mapSchemas( diff --git a/springwolf-ui/src/app/service/asyncapi/models/asyncapi.model.ts b/springwolf-ui/src/app/service/asyncapi/models/asyncapi.model.ts index 0508b3407..e03359534 100644 --- a/springwolf-ui/src/app/service/asyncapi/models/asyncapi.model.ts +++ b/springwolf-ui/src/app/service/asyncapi/models/asyncapi.model.ts @@ -6,10 +6,6 @@ import { ServerChannels } from "./channels.model"; import { ServerComponents } from "./components.model"; import { ServerOperations } from "./operations.model"; -export type ServerAsyncApiChannelMessage = - | ServerAsyncApiMessage - | { oneOf: ServerAsyncApiMessage[] }; - export interface ServerAsyncApi { asyncapi: string; info: ServerAsyncApiInfo; diff --git a/springwolf-ui/src/app/service/asyncapi/models/channels.model.ts b/springwolf-ui/src/app/service/asyncapi/models/channels.model.ts index 813097c08..0110201ff 100644 --- a/springwolf-ui/src/app/service/asyncapi/models/channels.model.ts +++ b/springwolf-ui/src/app/service/asyncapi/models/channels.model.ts @@ -7,7 +7,6 @@ export interface ServerChannels { } export interface ServerChannel { - address: string; description?: string; messages: Map; bindings: ServerBindings; diff --git a/springwolf-ui/src/app/service/asyncapi/models/info.models.ts b/springwolf-ui/src/app/service/asyncapi/models/info.models.ts index a30a8af67..e2fa24712 100644 --- a/springwolf-ui/src/app/service/asyncapi/models/info.models.ts +++ b/springwolf-ui/src/app/service/asyncapi/models/info.models.ts @@ -1,8 +1,14 @@ /* SPDX-License-Identifier: Apache-2.0 */ export interface ServerAsyncApiInfo { title: string; - version: string; + version?: string; description?: string; + // TODO: use contact + contact?: { + name?: string; + url?: string; + email?: string; + }; // TODO: use license license?: { name?: string; diff --git a/springwolf-ui/src/app/service/asyncapi/models/message.model.ts b/springwolf-ui/src/app/service/asyncapi/models/message.model.ts index 22a6e2694..eab0f11e1 100644 --- a/springwolf-ui/src/app/service/asyncapi/models/message.model.ts +++ b/springwolf-ui/src/app/service/asyncapi/models/message.model.ts @@ -5,7 +5,12 @@ export interface ServerAsyncApiMessage { name: string; title: string; description?: string; - payload: { $ref: string }; + payload: { + schemaFormat: string; + schema: { + $ref: string; + }; + }; headers: { $ref: string }; bindings: ServerBindings; } diff --git a/springwolf-ui/src/app/service/asyncapi/models/operations.model.ts b/springwolf-ui/src/app/service/asyncapi/models/operations.model.ts index 7ba5bf37c..4334a35b7 100644 --- a/springwolf-ui/src/app/service/asyncapi/models/operations.model.ts +++ b/springwolf-ui/src/app/service/asyncapi/models/operations.model.ts @@ -1,10 +1,21 @@ /* SPDX-License-Identifier: Apache-2.0 */ -import { ServerAsyncApiMessage } from "./message.model"; +import { ServerBindings } from "./bindings.model"; export interface ServerOperations { - action: "receive" | "send"; + [key: string]: ServerOperation; +} + +export type ServerOperationAction = "receive" | "send"; + +export interface ServerOperation { + action: ServerOperationAction; channel: { $ref: string; }; - messages: ServerAsyncApiMessage[]; + messages: ServerOperationMessage[]; + bindings: ServerBindings; +} + +export interface ServerOperationMessage { + $ref: string; } diff --git a/springwolf-ui/src/app/service/asyncapi/models/schema.model.ts b/springwolf-ui/src/app/service/asyncapi/models/schema.model.ts index f205a8891..59b587218 100644 --- a/springwolf-ui/src/app/service/asyncapi/models/schema.model.ts +++ b/springwolf-ui/src/app/service/asyncapi/models/schema.model.ts @@ -2,9 +2,9 @@ export interface ServerAsyncApiSchema { description?: string; type: string; - format: string; - enum: string[]; - properties?: Map; + format?: string; + enum?: string[]; + properties: Map; items?: ServerAsyncApiSchema; example?: | {