Skip to content

Commit

Permalink
feat: spec v3 support (update examples to v3.0.0) (#549)
Browse files Browse the repository at this point in the history
Co-authored-by: Khuda Dad Nomani <[email protected]>
  • Loading branch information
Souvikns and KhudaDad414 authored May 1, 2024
1 parent 827101c commit d8e3bd7
Show file tree
Hide file tree
Showing 11 changed files with 188 additions and 102 deletions.
29 changes: 29 additions & 0 deletions examples/anime-http/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Anime-HTTP

This application is a dummy application showcasing the use of HTTP adapter in Glee. This application makes and `GET` call to a third-party REST API to fetch the list of famous Anime.


## Prerequisites

- Node.js (version 12 or higher)

## How to run the Application

The application is divided into a `server` and a `client` which needs to be run simultaneously.

**To run Server**

```sh
cd server
npm run dev
```

**To run Client**

```sh
cd client
npm run dev
```


The Server needs to run first and then the client application. The server fetches the data from the third-party REST API when the client makes a `GET` API call to the server.
5 changes: 0 additions & 5 deletions examples/anime-http/client/asyncapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ operations:
$ref: '#/channels/trendingAnime'
messages:
- $ref: '#/components/messages/trendingAnimeMessage'
reply:
channel:
$ref: '#/channels/trendingAnime'
messages:
- $ref: '#/components/messages/trendingAnimeReply'
components:
messages:
testMessage:
Expand Down
11 changes: 6 additions & 5 deletions examples/anime-http/server/asyncapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ operations:
$ref: '#/channels/trendingAnime'
messages:
- $ref: '#/components/messages/trendingAnime'
reply:
channel:
$ref: "#/channels/trendingAnime"
messages:
- $ref: '#/components/messages/trendingAnimeReply'
trendingAnimeReply:
action: send
channel:
$ref: '#/channels/trendingAnime'
messages:
- $ref: '#/components/messages/trendingAnime'
components:
messages:
trendingAnime:
Expand Down
10 changes: 6 additions & 4 deletions examples/anime-http/server/functions/trendingAnimeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ export default async function (event) {
const replyPayload = event.payload
const replyQuery = event.query
return {
reply: [
send: [
{
payload: replyPayload,
query: replyQuery
},
],
query: replyQuery,
channel: 'trendingAnime'
}

]
}
}
2 changes: 1 addition & 1 deletion examples/crypto-websockets/server/asyncapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ channels:
token:
type: string
operations:
/price.subscribe:
sendPrice:
action: send
channel:
$ref: '#/channels/price'
Expand Down
46 changes: 32 additions & 14 deletions examples/flight-management/backend/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,49 @@
asyncapi: 2.4.0
asyncapi: 3.0.0
info:
title: Flight Board
version: 0.0.1
description: Flight Board offers real time flight info on all of the screens at an airport. This AsyncAPI file is only for the real time communication. We are using Glee to manage the WebSocket server as well as the REST API server, which is being created with Express.js.

description: >-
Flight Board offers real time flight info on all of the screens at an
airport. This AsyncAPI file is only for the real time communication. We are
using Glee to manage the WebSocket server as well as the REST API server,
which is being created with Express.js.
servers:
websockets:
url: ws://localhost:3000
host: 'localhost:3000'
protocol: ws
description: This Websocket server is available without authorization. It receives the changes that are made by different sources and updates the database and Flight Boards.
description: >-
This Websocket server is available without authorization. It receives the
changes that are made by different sources and updates the database and
Flight Boards.
channels:
/:
publish:
operationId: sendMessage
message:
oneOf:
- $ref: '#/components/messages/updateFlight'
- $ref: '#/components/messages/getFlights'
index:
address: /
messages:
updateFlight:
$ref: '#/components/messages/updateFlight'
getFlights:
$ref: '#/components/messages/getFlights'
bindings:
ws:
query:
additionalProperties: false
properties:
airport:
type: string
operations:
sendMessage:
action: receive
channel:
$ref: '#/channels/index'
messages:
- $ref: '#/components/messages/updateFlight'
- $ref: '#/components/messages/getFlights'
components:
messages:
getFlights:
summary: This message should be published when a board wants to receive all of the flights that depart or arrive at that airport.
summary: >-
This message should be published when a board wants to receive all of
the flights that depart or arrive at that airport.
payload:
type: object
additionalProperties: false
Expand All @@ -52,4 +68,6 @@ components:
eventName:
type: string
description: The name of the event.
enum: ['allFlights', 'updateFlight']
enum:
- allFlights
- updateFlight
36 changes: 25 additions & 11 deletions examples/kafka-test/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
asyncapi: 2.4.0
asyncapi: 3.0.0
info:
title: Kafka test
version: '1'
servers:
mykafka:
url: kafka://pkc-6ojv2.us-west4.gcp.confluent.cloud:9092
host: 'pkc-6ojv2.us-west4.gcp.confluent.cloud:9092'
protocol: kafka-secure
security:
- saslScramExample: []
- $ref: '#/components/securitySchemes/saslScramExample'
channels:
test:
publish:
operationId: onTest
message:
address: test
messages:
testMessage:
$ref: '#/components/messages/testMessage'
produce:
subscribe:
message:
address: produce
messages:
testMessage:
$ref: '#/components/messages/testMessage'
operations:
onTest:
action: receive
channel:
$ref: '#/channels/test'
messages:
- $ref: '#/components/messages/testMessage'
sendMessage:
action: send
channel:
$ref: '#/channels/produce'
messages:
- $ref: '#/components/messages/testMessage'
components:
messages:
testMessage:
payload:
type: object
properties:
test:
type: string
type: string
securitySchemes:
saslScramExample:
type: scramSha256
saslScramExample:
type: scramSha256
78 changes: 42 additions & 36 deletions examples/shrek-websockets/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@
asyncapi: 2.0.0

#
# Overal information for users of the application
#
asyncapi: 3.0.0
info:
title: Shrek App
version: '1.0.0'
description: |
Purpose of this app is to have some fun with AsyncAPI and WebSocket and define an interface for ... Shrek.
version: 1.0.0
description: >
Purpose of this app is to have some fun with AsyncAPI and WebSocket and
define an interface for ... Shrek.
![](https://media.giphy.com/media/10Ug6rDDuG3YoU/giphy-downsized.gif)
You can use this API to chat with Shrek bot or to get updates about artifical travels to different locations.
#
# Details on how to connect to the application
#
You can use this API to chat with Shrek bot or to get updates about
artifical travels to different locations.
servers:
swamp:
url: ws://localhost
host: localhost
protocol: ws

#
# Details about all the channels that you can listen to or send to messages
#
channels:
/chat:
subscribe:
summary: Client can receive chat messages.
operationId: subChatMessage
message:
chat:
address: /chat
messages:
receiveChatMessage:
$ref: '#/components/messages/chatMessage'
publish:
summary: Client can send chat messages.
operationId: pubChatMessage
message:
sendChatMessage:
$ref: '#/components/messages/chatMessage'
/travel/status:
subscribe:
summary: Client can receive travel info status.
operationId: subTravelInfo
message:
travelStatus:
address: /travel/status
messages:
subTravelInfo:
$ref: '#/components/messages/travelInfo'

#
# All reusable parts for readability and staying DRY
#
operations:
recieveChatMessage:
action: receive
channel:
$ref: '#/channels/chat'
summary: Client can send chat messages.
messages:
- $ref: '#/components/messages/chatMessage'
sendChatMessage:
action: send
channel:
$ref: '#/channels/chat'
summary: Client can receive chat messages.
messages:
- $ref: '#/components/messages/chatMessage'
sendTravelInfo:
action: send
channel:
$ref: '#/channels/travelStatus'
summary: Client can receive travel info status.
messages:
- $ref: '#/components/messages/travelInfo'
components:
messages:
chatMessage:
Expand All @@ -69,4 +75,4 @@ components:
type: string
arrival:
description: Time left to get there.
type: string
type: string
21 changes: 13 additions & 8 deletions examples/social-network/notifications-service/asyncapi.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
asyncapi: 2.2.0
asyncapi: 3.0.0
info:
title: Notifications Service
version: 0.1.0

servers:
mosquitto:
url: mqtt://test.mosquitto.org
host: test.mosquitto.org
protocol: mqtt
bindings:
mqtt:
clientId: notifications-service

channels:
post/liked:
publish:
operationId: onPostLiked
message:
postLiked:
address: post/liked
messages:
onPostLikedMmessage:
$ref: '../websocket-server/asyncapi.yaml#/components/messages/notifyPostLiked'
operations:
onPostLiked:
action: receive
channel:
$ref: '#/channels/postLiked'
messages:
- $ref: '#/channels/post~1liked/messages/onPostLikedMessage'
Loading

0 comments on commit d8e3bd7

Please sign in to comment.