From 93b50e00f77407cd6098ce39eddc875e5bf9879c Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Thu, 11 Nov 2021 15:40:44 +0100 Subject: [PATCH 01/11] Added documents and basic readme --- examples/social-media/backend.asyncapi.yaml | 46 ++++++++++++++ .../comments-service.asyncapi.yaml | 31 ++++++++++ .../social-media/dictionary.asyncapi.yaml | 60 +++++++++++++++++++ examples/social-media/frontend.asyncapi.yaml | 22 +++++++ .../notification-service.asyncapi.yaml | 20 +++++++ examples/social-media/public.asyncapi.yaml | 21 +++++++ examples/social-media/readme.md | 19 ++++++ 7 files changed, 219 insertions(+) create mode 100644 examples/social-media/backend.asyncapi.yaml create mode 100644 examples/social-media/comments-service.asyncapi.yaml create mode 100644 examples/social-media/dictionary.asyncapi.yaml create mode 100644 examples/social-media/frontend.asyncapi.yaml create mode 100644 examples/social-media/notification-service.asyncapi.yaml create mode 100644 examples/social-media/public.asyncapi.yaml create mode 100644 examples/social-media/readme.md diff --git a/examples/social-media/backend.asyncapi.yaml b/examples/social-media/backend.asyncapi.yaml new file mode 100644 index 00000000..01f49a98 --- /dev/null +++ b/examples/social-media/backend.asyncapi.yaml @@ -0,0 +1,46 @@ +asyncapi: 2.2.0 + +info: + title: Website Backend + version: 1.0.0 + +servers: + websiteWebSocketServer: + url: ws://mycompany.com/ws + protocol: ws + mosquitto: + url: mqtt://test.mosquitto.org + protocol: mqtt + bindings: + mqtt: + clientId: websocketServer + +channels: + comment/liked: + description: Notify all the services that a comment has been liked. + servers: ['mosquitto'] + subscribe: + message: + $ref: './dictionary.asyncapi.yaml#/components/messages/commentLiked' + like/comment: + description: When a comment like is received from the frontend. + servers: ['websiteWebSocketServer'] + publish: + message: + $ref: './dictionary.asyncapi.yaml#/components/messages/likeComment' + comment/{commentId}/changed: + description: When an event from the broker arrives telling us to update the comment likes count on the frontend. + parameters: + commentId: + schema: + $ref: './dictionary.asyncapi.yaml#/components/schemas/commentId' + servers: ['mosquitto'] + publish: + message: + $ref: './dictionary.asyncapi.yaml#/components/messages/commentChanged' + update/comment/likes: + description: Update comment likes count in the frontend. + servers: ['websiteWebSocketServer'] + subscribe: + message: + $ref: './dictionary.asyncapi.yaml#/components/messages/updateCommentLikes' \ No newline at end of file diff --git a/examples/social-media/comments-service.asyncapi.yaml b/examples/social-media/comments-service.asyncapi.yaml new file mode 100644 index 00000000..e35ddb34 --- /dev/null +++ b/examples/social-media/comments-service.asyncapi.yaml @@ -0,0 +1,31 @@ +asyncapi: 2.2.0 + +info: + title: Comments Service + version: 1.0.0 + description: This service is in charge of processing all the events related to comments. + +servers: + mosquitto: + url: mqtt://test.mosquitto.org + protocol: mqtt + bindings: + mqtt: + clientId: comment-service + +channels: + comment/liked: + description: Updates the likes count in the database and sends the new count to the broker. + publish: + message: + $ref: './dictionary.asyncapi.yaml#/components/messages/commentLiked' + comment/{commentId}/changed: + description: Sends the new count to the broker after it has been updated in the database. + parameters: + commentId: + schema: + $ref: './dictionary.asyncapi.yaml#/components/schemas/commentId' + subscribe: + message: + $ref: './dictionary.asyncapi.yaml#/components/messages/commentChanged' + diff --git a/examples/social-media/dictionary.asyncapi.yaml b/examples/social-media/dictionary.asyncapi.yaml new file mode 100644 index 00000000..feca6359 --- /dev/null +++ b/examples/social-media/dictionary.asyncapi.yaml @@ -0,0 +1,60 @@ +asyncapi: 2.2.0 + +info: + title: Dictionary for organization-wide definitions + version: 1.0.0 + +components: + messages: + commentLiked: + payload: + $ref: '#/components/schemas/commentLikedPayload' + likeComment: + payload: + $ref: '#/components/schemas/likeCommentPayload' + commentChanged: + payload: + $ref: '#/components/schemas/commentChangedPayload' + updateCommentLikes: + payload: + $ref: '#/components/schemas/updateCommentLikesPayload' + + schemas: + commentLikedPayload: + type: object + title: commentLikedPayload + additionalProperties: false + properties: + commentId: + allOf: + - $ref: '#/components/schemas/commentId' + - description: Id of the comment that was liked + likeCommentPayload: + type: object + title: likeCommentPayload + additionalProperties: false + properties: + commentId: + allOf: + - $ref: '#/components/schemas/commentId' + - description: Id of the comment that should be liked + commentChangedPayload: + type: object + title: commentChangedPayload + additionalProperties: false + properties: + commentId: + allOf: + - $ref: '#/components/schemas/commentId' + - description: Id of the comment that was changed, such as when someone liked it. + updateCommentLikesPayload: + type: object + title: updateCommentLikesPayload + additionalProperties: false + properties: + commentId: + allOf: + - $ref: '#/components/schemas/commentId' + - description: Id of the comment that was changed, such as when someone liked it. + commentId: + type: string diff --git a/examples/social-media/frontend.asyncapi.yaml b/examples/social-media/frontend.asyncapi.yaml new file mode 100644 index 00000000..061de8f1 --- /dev/null +++ b/examples/social-media/frontend.asyncapi.yaml @@ -0,0 +1,22 @@ +asyncapi: 2.2.0 + +info: + title: Website WebSocket Client + version: 1.0.0 + +servers: + websiteWebSocketServer: + url: ws://mycompany.com/ws + protocol: ws + +channels: + like/comment: + description: Notify the backend that a comment has been liked. + subscribe: + message: + $ref: './dictionary.asyncapi.yaml#/components/messages/likeComment' + update/comment/likes: + description: Update the UI when the comment likes count is updated. + publish: + message: + $ref: './dictionary.asyncapi.yaml#/components/messages/updateCommentLikes' \ No newline at end of file diff --git a/examples/social-media/notification-service.asyncapi.yaml b/examples/social-media/notification-service.asyncapi.yaml new file mode 100644 index 00000000..8b12e77f --- /dev/null +++ b/examples/social-media/notification-service.asyncapi.yaml @@ -0,0 +1,20 @@ +asyncapi: 2.2.0 + +info: + title: Notifications Service + version: 1.0.0 + +servers: + mosquitto: + url: mqtt://test.mosquitto.org + protocol: mqtt + bindings: + mqtt: + clientId: notification-service + +channels: + comment/liked: + description: When a "comment has been liked" message is received, it sends an SMS or push notification to the author. + publish: + message: + $ref: './dictionary.asyncapi.yaml#/components/messages/commentLiked' \ No newline at end of file diff --git a/examples/social-media/public.asyncapi.yaml b/examples/social-media/public.asyncapi.yaml new file mode 100644 index 00000000..156b82d8 --- /dev/null +++ b/examples/social-media/public.asyncapi.yaml @@ -0,0 +1,21 @@ +asyncapi: 2.2.0 + +info: + title: Public API + description: Public API for others to interact with the system + version: 1.0.0 + +servers: + mosquitto: + url: mqtt://test.mosquitto.org + protocol: mqtt + bindings: + mqtt: + clientId: public-api + +channels: + comment/liked: + description: When a "comment has been liked" message is received, it sends an SMS or push notification to the author. + publish: + message: + $ref: './dictionary.asyncapi.yaml#/components/messages/commentLiked' \ No newline at end of file diff --git a/examples/social-media/readme.md b/examples/social-media/readme.md new file mode 100644 index 00000000..791656b1 --- /dev/null +++ b/examples/social-media/readme.md @@ -0,0 +1,19 @@ +## Small social media example + +Say we have a social network, a very basic one, where all you can do is upvoting comments. + +The individual services that need to be defined are: + +- A frontend application where users interact through the website, where they can like comments. +- A backend WebSocket server that sends and receives events for the UI to update in real-time. +- A comment service which processes all events related to comments through a message broker. +- A public-facing API which allows others to get notified about updates. + +[![](https://mermaid.ink/img/eyJjb2RlIjoiXG5ncmFwaCBURFxuIHNlcnZlcjFbKHdzOi8vbXljb21wYW55LmNvbS93cyldXG5XZWJzaXRlQmFja2VuZFtXZWJzaXRlIEJhY2tlbmRdXG5XZWJzaXRlV2ViU29ja2V0Q2xpZW50W1dlYnNpdGUgV2ViU29ja2V0IENsaWVudF1cbldlYnNpdGVXZWJTb2NrZXRDbGllbnQgLS0gbGlrZS9jb21tZW50IC0tPiBzZXJ2ZXIxXG5zZXJ2ZXIxIC0tIGxpa2UvY29tbWVudCAtLT4gV2Vic2l0ZUJhY2tlbmRcbldlYnNpdGVCYWNrZW5kIC0tIHVwZGF0ZS9jb21tZW50L2xpa2VzIC0tPiBzZXJ2ZXIxXG5zZXJ2ZXIxIC0tIHVwZGF0ZS9jb21tZW50L2xpa2VzIC0tPiBXZWJzaXRlV2ViU29ja2V0Q2xpZW50XG5zZXJ2ZXIyWyhtcXR0Oi8vdGVzdC5tb3NxdWl0dG8ub3JnKV1cbldlYnNpdGVCYWNrZW5kIC0tIGNvbW1lbnQvbGlrZWQgLS0-IHNlcnZlcjJcbkNvbW1lbnRzU2VydmljZVtDb21tZW50cyBTZXJ2aWNlXVxuc2VydmVyMiAtLSBjb21tZW50L2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VzdC5tb3NxdWl0dG8ub3JnKV1cbldlYnNpdGVCYWNrZW5kIC0tIGNvbW1lbnQvbGlrZWQgLS0-IHNlcnZlcjJcbkNvbW1lbnRzU2VydmljZVtDb21tZW50cyBTZXJ2aWNlXVxuc2VydmVyMiAtLSBjb21tZW50L2xpa2VkIC0tPiBDb21tZW50c1NlcnZpY2Vcbk5vdGlmaWNhdGlvbnNTZXJ2aWNlW05vdGlmaWNhdGlvbnMgU2VydmljZV1cbnNlcnZlcjIgLS0gY29tbWVudC9saWtlZCAtLT4gTm90aWZpY2F0aW9uc1NlcnZpY2VcbkNvbW1lbnRzU2VydmljZSAtLSBcImNvbW1lbnQve2NvbW1lbnRJZH0vY2hhbmdlZFwiIC0tPiBzZXJ2ZXIyXG5zZXJ2ZXIyIC0tIFwiY29tbWVudC97Y29tbWVudElkfS9jaGFuZ2VkXCIgLS0-IFdlYnNpdGVCYWNrZW5kXG5QdWJsaWNBUElbUHVibGljIEFQSV1cbnNlcnZlcjIgLS0gXCJjb21tZW50L2xpa2VkXCIgLS0-IFB1YmxpY0FQSSIsIm1lcm1haWQiOiJ7XG4gIFwidGhlbWVcIjogXCJkYXJrXCJcbn0iLCJ1cGRhdGVFZGl0b3IiOmZhbHNlLCJhdXRvU3luYyI6dHJ1ZSwidXBkYXRlRGlhZ3JhbSI6ZmFsc2V9) + +This ensures that we try to describe the following use-cases mixed together: + +- A public API +- A WebSocket server and client +- A broker setup + From 0cf47646c51726a862b73d3ea3395bf6c59f77ac Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Thu, 11 Nov 2021 15:48:49 +0100 Subject: [PATCH 02/11] Added caption --- examples/social-media/readme.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/social-media/readme.md b/examples/social-media/readme.md index 791656b1..4a34171b 100644 --- a/examples/social-media/readme.md +++ b/examples/social-media/readme.md @@ -9,8 +9,13 @@ The individual services that need to be defined are: - A comment service which processes all events related to comments through a message broker. - A public-facing API which allows others to get notified about updates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iBzZXJ2ZXIyXG5zZXJ2ZXIyIC0tIFwiY29tbWVudC97Y29tbWVudElkfS9jaGFuZ2VkXCIgLS0-IFdlYnNpdGVCYWNrZW5kXG5QdWJsaWNBUElbUHVibGljIEFQSV1cbnNlcnZlcjIgLS0gXCJjb21tZW50L2xpa2VkXCIgLS0-IFB1YmxpY0FQSSIsIm1lcm1haWQiOiJ7XG4gIFwidGhlbWVcIjogXCJkYXJrXCJcbn0iLCJ1cGRhdGVFZGl0b3IiOmZhbHNlLCJhdXRvU3luYyI6dHJ1ZSwidXBkYXRlRGlhZ3JhbSI6ZmFsc2V9) +

+Fig.1 - Mermaid diagram for the system, partly generated using Cupid. +

+ This ensures that we try to describe the following use-cases mixed together: - A public API From aa9b95356d4784428ab3ee968794d438a127f4a7 Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Sat, 13 Nov 2021 10:38:07 +0100 Subject: [PATCH 03/11] Added links to applications --- examples/social-media/readme.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/social-media/readme.md b/examples/social-media/readme.md index 4a34171b..031de05e 100644 --- a/examples/social-media/readme.md +++ b/examples/social-media/readme.md @@ -4,10 +4,11 @@ Say we have a social network, a very basic one, where all you can do is upvoting The individual services that need to be defined are: -- A frontend application where users interact through the website, where they can like comments. -- A backend WebSocket server that sends and receives events for the UI to update in real-time. -- A comment service which processes all events related to comments through a message broker. -- A public-facing API which allows others to get notified about updates. +- [A frontend application (frontend.asyncapi.yaml)](./frontend.asyncapi.yaml) where users interact through the website, where they can like comments. +- [A backend WebSocket server (backend.asyncapi.yaml)](./backend.asyncapi.yaml) that sends and receives events for the UI to update in real-time. +- [A comment service (comments-service.asyncapi.yaml)](./comments-service.asyncapi.yaml) which processes all events related to comments through a message broker. +- [A notification service (notification-service.asyncapi.yaml)](./notification-service.asyncapi.yaml) which ensures all relevant parties to the comment is notified. +- [A public-facing API (public.asyncapi.yaml)](./public.asyncapi.yaml) which is an external application, where anyone can get notified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tPiBzZXJ2ZXIyXG5zZXJ2ZXIyIC0tIFwiY29tbWVudC97Y29tbWVudElkfS9jaGFuZ2VkXCIgLS0-IFdlYnNpdGVCYWNrZW5kXG5QdWJsaWNBUElbUHVibGljIEFQSV1cbnNlcnZlcjIgLS0gXCJjb21tZW50L2xpa2VkXCIgLS0-IFB1YmxpY0FQSSIsIm1lcm1haWQiOiJ7XG4gIFwidGhlbWVcIjogXCJkYXJrXCJcbn0iLCJ1cGRhdGVFZGl0b3IiOmZhbHNlLCJhdXRvU3luYyI6dHJ1ZSwidXBkYXRlRGlhZ3JhbSI6ZmFsc2V9) From b860cc461382c512b843edb5bb37c53c63f7b928 Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Sat, 13 Nov 2021 12:33:39 +0100 Subject: [PATCH 04/11] Added empty channels to dictionary --- examples/social-media/dictionary.asyncapi.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/social-media/dictionary.asyncapi.yaml b/examples/social-media/dictionary.asyncapi.yaml index feca6359..a3dcadeb 100644 --- a/examples/social-media/dictionary.asyncapi.yaml +++ b/examples/social-media/dictionary.asyncapi.yaml @@ -3,7 +3,7 @@ asyncapi: 2.2.0 info: title: Dictionary for organization-wide definitions version: 1.0.0 - +channels: {} components: messages: commentLiked: @@ -18,7 +18,6 @@ components: updateCommentLikes: payload: $ref: '#/components/schemas/updateCommentLikesPayload' - schemas: commentLikedPayload: type: object From 5c1a9d56fe59da16df878cc3510add438ffdbee5 Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Mon, 15 Nov 2021 10:35:17 +0100 Subject: [PATCH 05/11] Added link to cupid --- examples/social-media/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/social-media/readme.md b/examples/social-media/readme.md index 031de05e..7ae2d3ca 100644 --- a/examples/social-media/readme.md +++ b/examples/social-media/readme.md @@ -14,7 +14,7 @@ The individual services that need to be defined are: [![](https://mermaid.ink/img/eyJjb2R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XIyIC0tIFwiY29tbWVudC97Y29tbWVudElkfS9jaGFuZ2VkXCIgLS0-IFdlYnNpdGVCYWNrZW5kXG5QdWJsaWNBUElbUHVibGljIEFQSV1cbnNlcnZlcjIgLS0gXCJjb21tZW50L2xpa2VkXCIgLS0-IFB1YmxpY0FQSSIsIm1lcm1haWQiOiJ7XG4gIFwidGhlbWVcIjogXCJkYXJrXCJcbn0iLCJ1cGRhdGVFZGl0b3IiOmZhbHNlLCJhdXRvU3luYyI6dHJ1ZSwidXBkYXRlRGlhZ3JhbSI6ZmFsc2V9)

-Fig.1 - Mermaid diagram for the system, partly generated using Cupid. +Fig.1 - Mermaid diagram for the system, partly generated using Cupid.

This ensures that we try to describe the following use-cases mixed together: From 84e924cfa7eb0625c91ab81c7ba5bc0e983c5f64 Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Wed, 17 Nov 2021 13:07:59 +0100 Subject: [PATCH 06/11] Restructured setup --- .../asyncapi.yaml} | 10 ++-- .../asyncapi.yaml} | 6 +- examples/social-media/common/messages.yaml | 12 ++++ examples/social-media/common/schemas.yaml | 38 ++++++++++++ .../social-media/dictionary.asyncapi.yaml | 59 ------------------- .../asyncapi.yaml} | 4 +- .../asyncapi.yaml} | 2 +- .../asyncapi.yaml} | 2 +- examples/social-media/readme.md | 18 +++--- 9 files changed, 71 insertions(+), 80 deletions(-) rename examples/social-media/{backend.asyncapi.yaml => backend/asyncapi.yaml} (71%) rename examples/social-media/{comments-service.asyncapi.yaml => comments-service/asyncapi.yaml} (73%) create mode 100644 examples/social-media/common/messages.yaml create mode 100644 examples/social-media/common/schemas.yaml delete mode 100644 examples/social-media/dictionary.asyncapi.yaml rename examples/social-media/{frontend.asyncapi.yaml => frontend/asyncapi.yaml} (72%) rename examples/social-media/{notification-service.asyncapi.yaml => notification-service/asyncapi.yaml} (83%) rename examples/social-media/{public.asyncapi.yaml => public-api/asyncapi.yaml} (85%) diff --git a/examples/social-media/backend.asyncapi.yaml b/examples/social-media/backend/asyncapi.yaml similarity index 71% rename from examples/social-media/backend.asyncapi.yaml rename to examples/social-media/backend/asyncapi.yaml index 01f49a98..1c4a60af 100644 --- a/examples/social-media/backend.asyncapi.yaml +++ b/examples/social-media/backend/asyncapi.yaml @@ -21,26 +21,26 @@ channels: servers: ['mosquitto'] subscribe: message: - $ref: './dictionary.asyncapi.yaml#/components/messages/commentLiked' + $ref: '../common/messages.yaml#/commentLiked' like/comment: description: When a comment like is received from the frontend. servers: ['websiteWebSocketServer'] publish: message: - $ref: './dictionary.asyncapi.yaml#/components/messages/likeComment' + $ref: '../common/messages.yaml#/likeComment' comment/{commentId}/changed: description: When an event from the broker arrives telling us to update the comment likes count on the frontend. parameters: commentId: schema: - $ref: './dictionary.asyncapi.yaml#/components/schemas/commentId' + $ref: '../common/schemas.yaml#/commentId' servers: ['mosquitto'] publish: message: - $ref: './dictionary.asyncapi.yaml#/components/messages/commentChanged' + $ref: '../common/messages.yaml#/commentChanged' update/comment/likes: description: Update comment likes count in the frontend. servers: ['websiteWebSocketServer'] subscribe: message: - $ref: './dictionary.asyncapi.yaml#/components/messages/updateCommentLikes' \ No newline at end of file + $ref: '../common/messages.yaml#/updateCommentLikes' \ No newline at end of file diff --git a/examples/social-media/comments-service.asyncapi.yaml b/examples/social-media/comments-service/asyncapi.yaml similarity index 73% rename from examples/social-media/comments-service.asyncapi.yaml rename to examples/social-media/comments-service/asyncapi.yaml index e35ddb34..0c0bddfd 100644 --- a/examples/social-media/comments-service.asyncapi.yaml +++ b/examples/social-media/comments-service/asyncapi.yaml @@ -18,14 +18,14 @@ channels: description: Updates the likes count in the database and sends the new count to the broker. publish: message: - $ref: './dictionary.asyncapi.yaml#/components/messages/commentLiked' + $ref: '../common/messages.yaml#/commentLiked' comment/{commentId}/changed: description: Sends the new count to the broker after it has been updated in the database. parameters: commentId: schema: - $ref: './dictionary.asyncapi.yaml#/components/schemas/commentId' + $ref: '../common/schemas.yaml#/commentId' subscribe: message: - $ref: './dictionary.asyncapi.yaml#/components/messages/commentChanged' + $ref: '../common/messages.yaml#/commentChanged' diff --git a/examples/social-media/common/messages.yaml b/examples/social-media/common/messages.yaml new file mode 100644 index 00000000..2dbe6481 --- /dev/null +++ b/examples/social-media/common/messages.yaml @@ -0,0 +1,12 @@ +commentLiked: + payload: + $ref: './schemas.yaml#/commentLikedPayload' +likeComment: + payload: + $ref: './schemas.yaml#/likeCommentPayload' +commentChanged: + payload: + $ref: './schemas.yaml#/commentChangedPayload' +updateCommentLikes: + payload: + $ref: './schemas.yaml#/updateCommentLikesPayload' \ No newline at end of file diff --git a/examples/social-media/common/schemas.yaml b/examples/social-media/common/schemas.yaml new file mode 100644 index 00000000..b897fdc1 --- /dev/null +++ b/examples/social-media/common/schemas.yaml @@ -0,0 +1,38 @@ +commentLikedPayload: + type: object + title: commentLikedPayload + additionalProperties: false + properties: + commentId: + allOf: + - $ref: '#commentId' + - description: Id of the comment that was liked +likeCommentPayload: + type: object + title: likeCommentPayload + additionalProperties: false + properties: + commentId: + allOf: + - $ref: '#/commentId' + - description: Id of the comment that should be liked +commentChangedPayload: + type: object + title: commentChangedPayload + additionalProperties: false + properties: + commentId: + allOf: + - $ref: '#/commentId' + - description: Id of the comment that was changed, such as when someone liked it. +updateCommentLikesPayload: + type: object + title: updateCommentLikesPayload + additionalProperties: false + properties: + commentId: + allOf: + - $ref: '#/commentId' + - description: Id of the comment that was changed, such as when someone liked it. +commentId: + type: string diff --git a/examples/social-media/dictionary.asyncapi.yaml b/examples/social-media/dictionary.asyncapi.yaml deleted file mode 100644 index a3dcadeb..00000000 --- a/examples/social-media/dictionary.asyncapi.yaml +++ /dev/null @@ -1,59 +0,0 @@ -asyncapi: 2.2.0 - -info: - title: Dictionary for organization-wide definitions - version: 1.0.0 -channels: {} -components: - messages: - commentLiked: - payload: - $ref: '#/components/schemas/commentLikedPayload' - likeComment: - payload: - $ref: '#/components/schemas/likeCommentPayload' - commentChanged: - payload: - $ref: '#/components/schemas/commentChangedPayload' - updateCommentLikes: - payload: - $ref: '#/components/schemas/updateCommentLikesPayload' - schemas: - commentLikedPayload: - type: object - title: commentLikedPayload - additionalProperties: false - properties: - commentId: - allOf: - - $ref: '#/components/schemas/commentId' - - description: Id of the comment that was liked - likeCommentPayload: - type: object - title: likeCommentPayload - additionalProperties: false - properties: - commentId: - allOf: - - $ref: '#/components/schemas/commentId' - - description: Id of the comment that should be liked - commentChangedPayload: - type: object - title: commentChangedPayload - additionalProperties: false - properties: - commentId: - allOf: - - $ref: '#/components/schemas/commentId' - - description: Id of the comment that was changed, such as when someone liked it. - updateCommentLikesPayload: - type: object - title: updateCommentLikesPayload - additionalProperties: false - properties: - commentId: - allOf: - - $ref: '#/components/schemas/commentId' - - description: Id of the comment that was changed, such as when someone liked it. - commentId: - type: string diff --git a/examples/social-media/frontend.asyncapi.yaml b/examples/social-media/frontend/asyncapi.yaml similarity index 72% rename from examples/social-media/frontend.asyncapi.yaml rename to examples/social-media/frontend/asyncapi.yaml index 061de8f1..7462478f 100644 --- a/examples/social-media/frontend.asyncapi.yaml +++ b/examples/social-media/frontend/asyncapi.yaml @@ -14,9 +14,9 @@ channels: description: Notify the backend that a comment has been liked. subscribe: message: - $ref: './dictionary.asyncapi.yaml#/components/messages/likeComment' + $ref: '../common/messages.yaml#/likeComment' update/comment/likes: description: Update the UI when the comment likes count is updated. publish: message: - $ref: './dictionary.asyncapi.yaml#/components/messages/updateCommentLikes' \ No newline at end of file + $ref: '../common/messages.yaml#/updateCommentLikes' \ No newline at end of file diff --git a/examples/social-media/notification-service.asyncapi.yaml b/examples/social-media/notification-service/asyncapi.yaml similarity index 83% rename from examples/social-media/notification-service.asyncapi.yaml rename to examples/social-media/notification-service/asyncapi.yaml index 8b12e77f..9952c962 100644 --- a/examples/social-media/notification-service.asyncapi.yaml +++ b/examples/social-media/notification-service/asyncapi.yaml @@ -17,4 +17,4 @@ channels: description: When a "comment has been liked" message is received, it sends an SMS or push notification to the author. publish: message: - $ref: './dictionary.asyncapi.yaml#/components/messages/commentLiked' \ No newline at end of file + $ref: '../common/messages.yaml#/commentLiked' \ No newline at end of file diff --git a/examples/social-media/public.asyncapi.yaml b/examples/social-media/public-api/asyncapi.yaml similarity index 85% rename from examples/social-media/public.asyncapi.yaml rename to examples/social-media/public-api/asyncapi.yaml index 156b82d8..a160b352 100644 --- a/examples/social-media/public.asyncapi.yaml +++ b/examples/social-media/public-api/asyncapi.yaml @@ -18,4 +18,4 @@ channels: description: When a "comment has been liked" message is received, it sends an SMS or push notification to the author. publish: message: - $ref: './dictionary.asyncapi.yaml#/components/messages/commentLiked' \ No newline at end of file + $ref: '../common/messages.yaml#/commentLiked' \ No newline at end of file diff --git a/examples/social-media/readme.md b/examples/social-media/readme.md index 7ae2d3ca..457673ab 100644 --- a/examples/social-media/readme.md +++ b/examples/social-media/readme.md @@ -2,13 +2,13 @@ Say we have a social network, a very basic one, where all you can do is upvoting comments. -The individual services that need to be defined are: +The individual services are defined: -- [A frontend application (frontend.asyncapi.yaml)](./frontend.asyncapi.yaml) where users interact through the website, where they can like comments. -- [A backend WebSocket server (backend.asyncapi.yaml)](./backend.asyncapi.yaml) that sends and receives events for the UI to update in real-time. -- [A comment service (comments-service.asyncapi.yaml)](./comments-service.asyncapi.yaml) which processes all events related to comments through a message broker. -- [A notification service (notification-service.asyncapi.yaml)](./notification-service.asyncapi.yaml) which ensures all relevant parties to the comment is notified. -- [A public-facing API (public.asyncapi.yaml)](./public.asyncapi.yaml) which is an external application, where anyone can get notified about updates. +- [A frontend application (./frontend)](./frontend/asyncapi.yaml) where users interact through the website, where they can like comments. +- [A backend WebSocket server (./backend)](./backend/asyncapi.yaml) that sends and receives events for the UI to update in real-time. +- [A comment service (./comments-service)](./comments-service/asyncapi.yaml) which processes all events related to comments through a message broker. +- [A notification service (./notification-service)](./notification-service/asyncapi.yaml) which ensures all relevant parties to the comment is notified. +- [A public-facing API (./public-api)](./public-api/asyncapi.yaml) which is an external application, where anyone outside the organization can get notified about updates. [![](https://mermaid.ink/img/eyJjb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ZXIyIC0tIFwiY29tbWVudC97Y29tbWVudElkfS9jaGFuZ2VkXCIgLS0-IFdlYnNpdGVCYWNrZW5kXG5QdWJsaWNBUElbUHVibGljIEFQSV1cbnNlcnZlcjIgLS0gXCJjb21tZW50L2xpa2VkXCIgLS0-IFB1YmxpY0FQSSIsIm1lcm1haWQiOiJ7XG4gIFwidGhlbWVcIjogXCJkYXJrXCJcbn0iLCJ1cGRhdGVFZGl0b3IiOmZhbHNlLCJhdXRvU3luYyI6dHJ1ZSwidXBkYXRlRGlhZ3JhbSI6ZmFsc2V9) @@ -19,7 +19,7 @@ Fig.1 - Mermaid diagram for the system, partly generated using Date: Wed, 17 Nov 2021 13:40:09 +0100 Subject: [PATCH 08/11] Updated readme --- examples/social-media/readme.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/social-media/readme.md b/examples/social-media/readme.md index 457673ab..5aba8e92 100644 --- a/examples/social-media/readme.md +++ b/examples/social-media/readme.md @@ -2,7 +2,7 @@ Say we have a social network, a very basic one, where all you can do is upvoting comments. -The individual services are defined: +The individual services are defined as such: - [A frontend application (./frontend)](./frontend/asyncapi.yaml) where users interact through the website, where they can like comments. - [A backend WebSocket server (./backend)](./backend/asyncapi.yaml) that sends and receives events for the UI to update in real-time. @@ -22,4 +22,5 @@ This ensures that we try to describe the following use-cases mixed together: - A public API, and how others may interact with our system. - A broker setup to include the most widely used scenario - A WebSocket server and client to ensure we dont focus only on broker centric systems. +- Reusability where possible, to ensure no dublication of definitions From 2b499c11c869282710bad5e28424bc8993f3cad4 Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Mon, 22 Nov 2021 16:21:21 +0100 Subject: [PATCH 09/11] Update examples/social-media/common/schemas.yaml Co-authored-by: Chris Eich --- examples/social-media/common/schemas.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/social-media/common/schemas.yaml b/examples/social-media/common/schemas.yaml index b897fdc1..d05286b1 100644 --- a/examples/social-media/common/schemas.yaml +++ b/examples/social-media/common/schemas.yaml @@ -5,7 +5,7 @@ commentLikedPayload: properties: commentId: allOf: - - $ref: '#commentId' + - $ref: '#/commentId' - description: Id of the comment that was liked likeCommentPayload: type: object From c6b004d3ceb12a43ec0ac3e55cd2c7e97f9199be Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Fri, 3 Dec 2021 17:27:28 +0100 Subject: [PATCH 10/11] Added counter --- examples/social-media/common/messages.yaml | 10 +++++++--- examples/social-media/common/schemas.yaml | 12 ++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/examples/social-media/common/messages.yaml b/examples/social-media/common/messages.yaml index 2dbe6481..33825171 100644 --- a/examples/social-media/common/messages.yaml +++ b/examples/social-media/common/messages.yaml @@ -1,12 +1,16 @@ -commentLiked: +commentLiked: + description: Message that is being sent when a comment has been liked by someone. payload: $ref: './schemas.yaml#/commentLikedPayload' likeComment: + description: Message that is being sent when someone wants to like a comment. payload: $ref: './schemas.yaml#/likeCommentPayload' -commentChanged: +commentChanged: + description: Message that is being sent when a comment have been updated. payload: - $ref: './schemas.yaml#/commentChangedPayload' + $ref: './schemas.yaml#/commentChanged' updateCommentLikes: + description: Message that is being sent when a comment have been updated. payload: $ref: './schemas.yaml#/updateCommentLikesPayload' \ No newline at end of file diff --git a/examples/social-media/common/schemas.yaml b/examples/social-media/common/schemas.yaml index d05286b1..e9eb9984 100644 --- a/examples/social-media/common/schemas.yaml +++ b/examples/social-media/common/schemas.yaml @@ -16,6 +16,10 @@ likeCommentPayload: allOf: - $ref: '#/commentId' - description: Id of the comment that should be liked + likedBy: + allOf: + - $ref: '#/commentId' + - description: The id of the user that have liked the comment commentChangedPayload: type: object title: commentChangedPayload @@ -25,6 +29,9 @@ commentChangedPayload: allOf: - $ref: '#/commentId' - description: Id of the comment that was changed, such as when someone liked it. + likeCount: + type: integer + description: The new like count of how many have liked the comment. updateCommentLikesPayload: type: object title: updateCommentLikesPayload @@ -34,5 +41,10 @@ updateCommentLikesPayload: allOf: - $ref: '#/commentId' - description: Id of the comment that was changed, such as when someone liked it. + likeCount: + type: integer + description: The new like count of how many have liked the comment. commentId: type: string +userId: + type: string \ No newline at end of file From ed48a016f1df1c4b6c14deee1febab2737062ac4 Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Fri, 3 Dec 2021 17:42:52 +0100 Subject: [PATCH 11/11] Update examples/social-media/common/schemas.yaml Co-authored-by: Chris Eich --- examples/social-media/common/schemas.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/social-media/common/schemas.yaml b/examples/social-media/common/schemas.yaml index e9eb9984..583d55d8 100644 --- a/examples/social-media/common/schemas.yaml +++ b/examples/social-media/common/schemas.yaml @@ -18,7 +18,7 @@ likeCommentPayload: - description: Id of the comment that should be liked likedBy: allOf: - - $ref: '#/commentId' + - $ref: '#/userId' - description: The id of the user that have liked the comment commentChangedPayload: type: object