diff --git a/apps/studio/src/examples/ibmmq.yml b/apps/studio/src/examples/ibmmq.yml index 60cd3c9ca..af015edcd 100644 --- a/apps/studio/src/examples/ibmmq.yml +++ b/apps/studio/src/examples/ibmmq.yml @@ -1,32 +1,42 @@ -asyncapi: 2.6.0 +asyncapi: 3.0.0 info: title: Record Label Service version: 1.1.0 description: This service is in charge of processing music license: name: Apache License 2.0 - url: https://www.apache.org/licenses/LICENSE-2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0' servers: production: - url: 'ibmmq://localhost:1414/QM1/DEV.APP.SVRCONN' + host: 'localhost:1414' + pathname: /QM1/DEV.APP.SVRCONN protocol: ibmmq-secure description: Production Instance 1 bindings: ibmmq: cipherSpec: ANY_TLS12 channels: - song/released: - publish: - operationId: publish - message: - $ref: '#/components/messages/song' - subscribe: - operationId: subscribe - message: - $ref: '#/components/messages/song' + songReleased: + address: song/released + messages: + Song: + $ref: '#/components/messages/Song' +operations: + receiveSong: + action: receive + channel: + $ref: '#/channels/songReleased' + messages: + - $ref: '#/components/messages/Song' + sendSong: + action: send + channel: + $ref: '#/channels/songReleased' + messages: + - $ref: '#/components/messages/Song' components: messages: - song: + Song: payload: type: object properties: @@ -44,4 +54,4 @@ components: description: Primary song genre length: type: integer - description: Track length in seconds + description: Track length in seconds \ No newline at end of file diff --git a/apps/studio/src/examples/index.tsx b/apps/studio/src/examples/index.tsx index 9c2dca921..b166ad96d 100644 --- a/apps/studio/src/examples/index.tsx +++ b/apps/studio/src/examples/index.tsx @@ -13,6 +13,7 @@ import invalid from './tutorials/invalid.yml'; // real world examples import slack from './real-world/slack-rtm.yml'; import gitterStreaming from './real-world/gitter-streaming.yml'; +import kraken from './real-world/kraken-api-request-reply-filter.yml'; const templateTypes = { protocol: 'protocol-example', @@ -74,5 +75,11 @@ export default [ description: () => <>Gitter Streaming API from https://stream.gitter.im. Using HTTP protocol., template: gitterStreaming, type: templateTypes.realExample + }, + { + title: 'Kraken Websockets API', + description: () => <>This Kraken Websocket specification. Using Websocket with request / reply, + template: kraken, + type: templateTypes.realExample } ]; diff --git a/apps/studio/src/examples/real-world/gitter-streaming.yml b/apps/studio/src/examples/real-world/gitter-streaming.yml index 29efd2e75..90a587828 100644 --- a/apps/studio/src/examples/real-world/gitter-streaming.yml +++ b/apps/studio/src/examples/real-world/gitter-streaming.yml @@ -1,42 +1,45 @@ -asyncapi: '2.6.0' -id: 'urn:com:gitter:streaming:api' +asyncapi: 3.0.0 +id: 'tag:stream.gitter.im,2022:api' info: title: Gitter Streaming API - version: '1.0.0' - + version: 1.0.0 servers: production: - url: https://stream.gitter.im/v1 + host: stream.gitter.im + pathname: /v1 protocol: https protocolVersion: '1.1' security: - - httpBearerToken: [] - + - $ref: '#/components/securitySchemes/httpBearerToken' channels: - /rooms/{roomId}/{resource}: + rooms: + address: '/rooms/{roomId}/{resource}' + messages: + chatMessage: + $ref: '#/components/messages/chatMessage' + heartbeat: + $ref: '#/components/messages/heartbeat' parameters: roomId: description: Id of the Gitter room. - schema: - type: string - examples: - - 53307860c3599d1de448e19d + examples: + - 53307860c3599d1de448e19d resource: + enum: + - chatMessages + - events description: The resource to consume. - schema: - type: string - enum: - - chatMessages - - events - subscribe: - bindings: - http: - type: response - message: - oneOf: - - $ref: '#/components/messages/chatMessage' - - $ref: '#/components/messages/heartbeat' - +operations: + sendRoomInfo: + action: send + channel: + $ref: '#/channels/rooms' + bindings: + http: + method: POST + messages: + - $ref: '#/components/messages/chatMessage' + - $ref: '#/components/messages/heartbeat' components: securitySchemes: httpBearerToken: @@ -44,121 +47,132 @@ components: scheme: bearer messages: chatMessage: - schemaFormat: 'application/schema+yaml;version=draft-07' summary: >- - A message represents an individual chat message sent to a room. - They are a sub-resource of a room. + A message represents an individual chat message sent to a room. They are + a sub-resource of a room. payload: - type: object - properties: - id: - type: string - description: ID of the message. - text: - type: string - description: Original message in plain-text/markdown. - html: - type: string - description: HTML formatted message. - sent: - type: string - format: date-time - description: ISO formatted date of the message. - fromUser: - type: object - description: User that sent the message. - properties: - id: - type: string - description: Gitter User ID. - username: - type: string - description: Gitter/GitHub username. - displayName: - type: string - description: Gitter/GitHub user real name. - url: - type: string - description: Path to the user on Gitter. - avatarUrl: - type: string - format: uri - description: User avatar URI. - avatarUrlSmall: - type: string - format: uri - description: User avatar URI (small). - avatarUrlMedium: - type: string - format: uri - description: User avatar URI (medium). - v: - type: number - description: Version. - gv: - type: string - description: Stands for "Gravatar version" and is used for cache busting. - unread: - type: boolean - description: Boolean that indicates if the current user has read the message. - readBy: - type: number - description: Number of users that have read the message. - urls: - type: array - description: List of URLs present in the message. - items: + schemaFormat: application/schema+yaml;version=draft-07 + schema: + type: object + properties: + id: + type: string + description: ID of the message. + text: type: string - format: uri - mentions: - type: array - description: List of @Mentions in the message. - items: + description: Original message in plain-text/markdown. + html: + type: string + description: HTML formatted message. + sent: + type: string + format: date-time + description: ISO formatted date of the message. + fromUser: type: object + description: User that sent the message. properties: - screenName: + id: type: string - userId: + description: Gitter User ID. + username: type: string - userIds: - type: array - items: - type: string - issues: - type: array - description: 'List of #Issues referenced in the message.' - items: - type: object - properties: - number: + description: Gitter/GitHub username. + displayName: + type: string + description: Gitter/GitHub user real name. + url: + type: string + description: Path to the user on Gitter. + avatarUrl: + type: string + format: uri + description: User avatar URI. + avatarUrlSmall: + type: string + format: uri + description: User avatar URI (small). + avatarUrlMedium: + type: string + format: uri + description: User avatar URI (medium). + v: + type: number + description: Version. + gv: type: string - meta: - type: array - description: Metadata. This is currently not used for anything. - items: {} - v: - type: number - description: Version. - gv: - type: string - description: Stands for "Gravatar version" and is used for cache busting. + description: Stands for "Gravatar version" and is used for cache busting. + unread: + type: boolean + description: Boolean that indicates if the current user has read the message. + readBy: + type: number + description: Number of users that have read the message. + urls: + type: array + description: List of URLs present in the message. + items: + type: string + format: uri + mentions: + type: array + description: List of @Mentions in the message. + items: + type: object + properties: + screenName: + type: string + userId: + type: string + userIds: + type: array + items: + type: string + issues: + type: array + description: 'List of #Issues referenced in the message.' + items: + type: object + properties: + number: + type: string + meta: + type: array + description: Metadata. This is currently not used for anything. + items: {} + v: + type: number + description: Version. + gv: + type: string + description: Stands for "Gravatar version" and is used for cache busting. bindings: http: - $ref: '#/components/messageBindings/streamingHeaders' - + headers: + type: object + properties: + Transfer-Encoding: + type: string + const: chunked + Trailer: + type: string + const: \r\n heartbeat: - schemaFormat: 'application/schema+yaml;version=draft-07' summary: Its purpose is to keep the connection alive. payload: - type: string - enum: ["\r\n"] + schemaFormat: application/schema+yaml;version=draft-07 + schema: + type: string + enum: + - "\r\n" bindings: http: - $ref: '#/components/messageBindings/streamingHeaders' - - messageBindings: - streamingHeaders: - http: - headers: - 'Transfer-Encoding': 'chunked' - Trailer: '\r\n' \ No newline at end of file + headers: + type: object + properties: + Transfer-Encoding: + type: string + const: chunked + Trailer: + type: string + const: \r\n \ No newline at end of file diff --git a/apps/studio/src/examples/real-world/kraken-api-request-reply-filter.yml b/apps/studio/src/examples/real-world/kraken-api-request-reply-filter.yml new file mode 100644 index 000000000..7ca161506 --- /dev/null +++ b/apps/studio/src/examples/real-world/kraken-api-request-reply-filter.yml @@ -0,0 +1,388 @@ +asyncapi: 3.0.0 + +info: + title: Kraken Websockets API + version: '1.8.0' + description: | + WebSockets API offers real-time market data updates. WebSockets is a bidirectional protocol offering fastest real-time data, helping you build real-time applications. The public message types presented below do not require authentication. Private-data messages can be subscribed on a separate authenticated endpoint. + + ### General Considerations + + - TLS with SNI (Server Name Indication) is required in order to establish a Kraken WebSockets API connection. See Cloudflare's [What is SNI?](https://www.cloudflare.com/learning/ssl/what-is-sni/) guide for more details. + - All messages sent and received via WebSockets are encoded in JSON format + - All decimal fields (including timestamps) are quoted to preserve precision. + - Timestamps should not be considered unique and not be considered as aliases for transaction IDs. Also, the granularity of timestamps is not representative of transaction rates. + - At least one private message should be subscribed to keep the authenticated client connection open. + - Please use REST API endpoint [AssetPairs](https://www.kraken.com/features/api#get-tradable-pairs) to fetch the list of pairs which can be subscribed via WebSockets API. For example, field 'wsname' gives the supported pairs name which can be used to subscribe. + - Cloudflare imposes a connection/re-connection rate limit (per IP address) of approximately 150 attempts per rolling 10 minutes. If this is exceeded, the IP is banned for 10 minutes. + - Recommended reconnection behaviour is to (1) attempt reconnection instantly up to a handful of times if the websocket is dropped randomly during normal operation but (2) after maintenance or extended downtime, attempt to reconnect no more quickly than once every 5 seconds. There is no advantage to reconnecting more rapidly after maintenance during cancel_only mode. + + +channels: + currencyExchange: + address: / + messages: + ping: + $ref: '#/components/messages/ping' + pong: + $ref: '#/components/messages/pong' + heartbeat: + $ref: '#/components/messages/heartbeat' + systemStatus: + $ref: '#/components/messages/systemStatus' + subscriptionStatus: + $ref: '#/components/messages/subscriptionStatus' + subscribe: + $ref: '#/components/messages/subscribe' + unsubscribe: + $ref: '#/components/messages/unsubscribe' + dummyCurrencyInfo: + $ref: '#/components/messages/dummyCurrencyInfo' + + +operations: + receivePing: + action: receive + channel: + $ref: '#/channels/currencyExchange' + reply: + channel: + $ref: '#/channels/currencyExchange' + messages: + - $ref: '#/components/messages/pong' + messages: + - $ref: '#/components/messages/ping' + sendHeartbeat: + action: send + channel: + $ref: '#/channels/currencyExchange' + messages: + - $ref: '#/components/messages/heartbeat' + systemStatus: + action: send + channel: + $ref: '#/channels/currencyExchange' + messages: + - $ref: '#/components/messages/systemStatus' + receiveSubscribeRequest: + action: receive + channel: + $ref: '#/channels/currencyExchange' + reply: + channel: + $ref: '#/channels/currencyExchange' + messages: + - $ref: '#/components/messages/subscriptionStatus' + - $ref: '#/components/messages/dummyCurrencyInfo' + messages: + - $ref: '#/components/messages/subscribe' + receiveUnsubscribeRequest: + action: receive + channel: + $ref: '#/channels/currencyExchange' + reply: + channel: + $ref: '#/channels/currencyExchange' + messages: + - $ref: '#/components/messages/subscriptionStatus' + messages: + - $ref: '#/components/messages/unsubscribe' + + +components: + messages: + dummyCurrencyInfo: + summary: Dummy message with no real life details + description: It is here in this example to showcase that there is an additional message that normally is of a complex structure. It represents actually currency exchange value to show a reply to operation receiveSubscribeRequest with more than one possible message. + payload: + type: object + properties: + event: + type: string + const: currencyInfo + reqid: + $ref: '#/components/schemas/reqid' + data: + type: object + required: + - event + correlationId: + location: '$message.payload#/reqid' + + ping: + summary: Ping server to determine whether connection is alive + description: Client can ping server to determine whether connection is alive, server responds with pong. This is an application level ping as opposed to default ping in websockets standard which is server initiated + payload: + $ref: '#/components/schemas/ping' + correlationId: + location: '$message.payload#/reqid' + + pong: + summary: Pong is a response to ping message + description: Server pong response to a ping to determine whether connection is alive. This is an application level pong as opposed to default pong in websockets standard which is sent by client in response to a ping + payload: + $ref: '#/components/schemas/pong' + correlationId: + location: '$message.payload#/reqid' + + subscribe: + description: Subscribe to a topic on a single or multiple currency pairs. + payload: + $ref: '#/components/schemas/subscribe' + correlationId: + location: '$message.payload#/reqid' + unsubscribe: + description: Unsubscribe, can specify a channelID or multiple currency pairs. + payload: + $ref: '#/components/schemas/unsubscribe' + correlationId: + location: '$message.payload#/reqid' + subscriptionStatus: + description: Subscription status response to subscribe, unsubscribe or exchange initiated unsubscribe. + payload: + $ref: '#/components/schemas/subscriptionStatus' + examples: + - payload: + channelID: 10001 + channelName: ohlc-5 + event: subscriptionStatus + pair: XBT/EUR + reqid: 42 + status: unsubscribed + subscription: + interval: 5 + name: ohlc + - payload: + errorMessage: Subscription depth not supported + event: subscriptionStatus + pair: XBT/USD + status: error + subscription: + depth: 42 + name: book + + systemStatus: + description: Status sent on connection or system status changes. + payload: + $ref: '#/components/schemas/systemStatus' + + heartbeat: + description: Server heartbeat sent if no subscription traffic within 1 second (approximately) + payload: + $ref: '#/components/schemas/heartbeat' + + + schemas: + ping: + type: object + properties: + event: + type: string + const: ping + reqid: + $ref: '#/components/schemas/reqid' + required: + - event + heartbeat: + type: object + properties: + event: + type: string + const: heartbeat + pong: + type: object + properties: + event: + type: string + const: pong + reqid: + $ref: '#/components/schemas/reqid' + systemStatus: + type: object + properties: + event: + type: string + const: systemStatus + connectionID: + type: integer + description: The ID of the connection + status: + $ref: '#/components/schemas/status' + version: + type: string + status: + type: string + enum: + - online + - maintenance + - cancel_only + - limit_only + - post_only + subscribe: + type: object + properties: + event: + type: string + const: subscribe + reqid: + $ref: '#/components/schemas/reqid' + pair: + $ref: '#/components/schemas/pair' + subscription: + type: object + properties: + depth: + $ref: '#/components/schemas/depth' + interval: + $ref: '#/components/schemas/interval' + name: + $ref: '#/components/schemas/name' + ratecounter: + $ref: '#/components/schemas/ratecounter' + snapshot: + $ref: '#/components/schemas/snapshot' + token: + $ref: '#/components/schemas/token' + required: + - name + required: + - event + unsubscribe: + type: object + properties: + event: + type: string + const: unsubscribe + reqid: + $ref: '#/components/schemas/reqid' + pair: + $ref: '#/components/schemas/pair' + subscription: + type: object + properties: + depth: + $ref: '#/components/schemas/depth' + interval: + $ref: '#/components/schemas/interval' + name: + $ref: '#/components/schemas/name' + token: + $ref: '#/components/schemas/token' + required: + - name + required: + - event + subscriptionStatus: + type: object + oneOf: + - $ref: '#/components/schemas/subscriptionStatusError' + - $ref: '#/components/schemas/subscriptionStatusSuccess' + subscriptionStatusError: + allOf: + - properties: + errorMessage: + type: string + required: + - errorMessage + - $ref: '#/components/schemas/subscriptionStatusCommon' + subscriptionStatusSuccess: + allOf: + - properties: + channelID: + type: integer + description: ChannelID on successful subscription, applicable to public messages only. + channelName: + type: string + description: Channel Name on successful subscription. For payloads 'ohlc' and 'book', respective interval or depth will be added as suffix. + required: + - channelID + - channelName + - $ref: '#/components/schemas/subscriptionStatusCommon' + subscriptionStatusCommon: + type: object + required: + - event + properties: + event: + type: string + const: subscriptionStatus + reqid: + $ref: '#/components/schemas/reqid' + pair: + $ref: '#/components/schemas/pair' + status: + $ref: '#/components/schemas/status' + subscription: + required: + - name + type: object + properties: + depth: + $ref: '#/components/schemas/depth' + interval: + $ref: '#/components/schemas/interval' + maxratecount: + $ref: '#/components/schemas/maxratecount' + name: + $ref: '#/components/schemas/name' + token: + $ref: '#/components/schemas/token' + interval: + type: integer + description: Time interval associated with ohlc subscription in minutes. + default: 1 + enum: + - 1 + - 5 + - 15 + - 30 + - 60 + - 240 + - 1440 + - 10080 + - 21600 + name: + type: string + description: The name of the channel you subscribe too. + enum: + - book + - ohlc + - openOrders + - ownTrades + - spread + - ticker + - trade + token: + type: string + description: base64-encoded authentication token for private-data endpoints. + depth: + type: integer + default: 10 + enum: + - 10 + - 25 + - 100 + - 500 + - 1000 + description: Depth associated with book subscription in number of levels each side. + maxratecount: + type: integer + description: Max rate-limit budget. Compare to the ratecounter field in the openOrders updates to check whether you are approaching the rate limit. + ratecounter: + type: boolean + default: false + description: Whether to send rate-limit counter in updates (supported only for openOrders subscriptions) + snapshot: + type: boolean + default: true + description: Whether to send historical feed data snapshot upon subscription (supported only for ownTrades subscriptions) + reqid: + type: integer + description: client originated ID reflected in response message. + pair: + type: array + description: Array of currency pairs. + items: + type: string + description: Format of each pair is "A/B", where A and B are ISO 4217-A3 for standardized assets and popular unique symbol if not standardized. + pattern: '[A-Z\s]+\/[A-Z\s]+' \ No newline at end of file diff --git a/apps/studio/src/examples/real-world/slack-rtm.yml b/apps/studio/src/examples/real-world/slack-rtm.yml index fb984a4e7..4c0c9209f 100644 --- a/apps/studio/src/examples/real-world/slack-rtm.yml +++ b/apps/studio/src/examples/real-world/slack-rtm.yml @@ -1,79 +1,178 @@ -asyncapi: '2.6.0' -id: 'urn:com:slack:rtm:api' +asyncapi: 3.0.0 +id: 'wss://wss-primary.slack.com/websocket' info: title: Slack Real Time Messaging API - version: '1.0.0' - + version: 1.0.0 servers: production: - url: https://slack.com/api/rtm.connect + host: slack.com + pathname: /api/rtm.connect protocol: https protocolVersion: '1.1' security: - - token: [] - + - $ref: '#/components/securitySchemes/token' channels: - /: - publish: - message: + root: + address: / + messages: + outgoingMessage: $ref: '#/components/messages/outgoingMessage' - subscribe: + hello: + $ref: '#/components/messages/hello' + connectionError: + $ref: '#/components/messages/connectionError' + accountsChanged: + $ref: '#/components/messages/accountsChanged' + botAdded: + $ref: '#/components/messages/botAdded' + botChanged: + $ref: '#/components/messages/botChanged' + channelArchive: + $ref: '#/components/messages/channelArchive' + channelCreated: + $ref: '#/components/messages/channelCreated' + channelDeleted: + $ref: '#/components/messages/channelDeleted' + channelHistoryChanged: + $ref: '#/components/messages/channelHistoryChanged' + channelJoined: + $ref: '#/components/messages/channelJoined' + channelLeft: + $ref: '#/components/messages/channelLeft' + channelMarked: + $ref: '#/components/messages/channelMarked' + channelRename: + $ref: '#/components/messages/channelRename' + channelUnarchive: + $ref: '#/components/messages/channelUnarchive' + commandsChanged: + $ref: '#/components/messages/commandsChanged' + dndUpdated: + $ref: '#/components/messages/dndUpdated' + dndUpdatedUser: + $ref: '#/components/messages/dndUpdatedUser' + emailDomainChanged: + $ref: '#/components/messages/emailDomainChanged' + emojiRemoved: + $ref: '#/components/messages/emojiRemoved' + emojiAdded: + $ref: '#/components/messages/emojiAdded' + fileChange: + $ref: '#/components/messages/fileChange' + fileCommentAdded: + $ref: '#/components/messages/fileCommentAdded' + fileCommentDeleted: + $ref: '#/components/messages/fileCommentDeleted' + fileCommentEdited: + $ref: '#/components/messages/fileCommentEdited' + fileCreated: + $ref: '#/components/messages/fileCreated' + fileDeleted: + $ref: '#/components/messages/fileDeleted' + filePublic: + $ref: '#/components/messages/filePublic' + fileShared: + $ref: '#/components/messages/fileShared' + fileUnshared: + $ref: '#/components/messages/fileUnshared' + goodbye: + $ref: '#/components/messages/goodbye' + groupArchive: + $ref: '#/components/messages/groupArchive' + groupClose: + $ref: '#/components/messages/groupClose' + groupHistoryChanged: + $ref: '#/components/messages/groupHistoryChanged' + groupJoined: + $ref: '#/components/messages/groupJoined' + groupLeft: + $ref: '#/components/messages/groupLeft' + groupMarked: + $ref: '#/components/messages/groupMarked' + groupOpen: + $ref: '#/components/messages/groupOpen' + groupRename: + $ref: '#/components/messages/groupRename' + groupUnarchive: + $ref: '#/components/messages/groupUnarchive' + imClose: + $ref: '#/components/messages/imClose' + imCreated: + $ref: '#/components/messages/imCreated' + imMarked: + $ref: '#/components/messages/imMarked' + imOpen: + $ref: '#/components/messages/imOpen' + manualPresenceChange: + $ref: '#/components/messages/manualPresenceChange' + memberJoinedChannel: + $ref: '#/components/messages/memberJoinedChannel' message: - oneOf: - - $ref: '#/components/messages/hello' - - $ref: '#/components/messages/connectionError' - - $ref: '#/components/messages/accountsChanged' - - $ref: '#/components/messages/botAdded' - - $ref: '#/components/messages/botChanged' - - $ref: '#/components/messages/channelArchive' - - $ref: '#/components/messages/channelCreated' - - $ref: '#/components/messages/channelDeleted' - - $ref: '#/components/messages/channelHistoryChanged' - - $ref: '#/components/messages/channelJoined' - - $ref: '#/components/messages/channelLeft' - - $ref: '#/components/messages/channelMarked' - - $ref: '#/components/messages/channelRename' - - $ref: '#/components/messages/channelUnarchive' - - $ref: '#/components/messages/commandsChanged' - - $ref: '#/components/messages/dndUpdated' - - $ref: '#/components/messages/dndUpdatedUser' - - $ref: '#/components/messages/emailDomainChanged' - - $ref: '#/components/messages/emojiRemoved' - - $ref: '#/components/messages/emojiAdded' - - $ref: '#/components/messages/fileChange' - - $ref: '#/components/messages/fileCommentAdded' - - $ref: '#/components/messages/fileCommentDeleted' - - $ref: '#/components/messages/fileCommentEdited' - - $ref: '#/components/messages/fileCreated' - - $ref: '#/components/messages/fileDeleted' - - $ref: '#/components/messages/filePublic' - - $ref: '#/components/messages/fileShared' - - $ref: '#/components/messages/fileUnshared' - - $ref: '#/components/messages/goodbye' - - $ref: '#/components/messages/groupArchive' - - $ref: '#/components/messages/groupClose' - - $ref: '#/components/messages/groupHistoryChanged' - - $ref: '#/components/messages/groupJoined' - - $ref: '#/components/messages/groupLeft' - - $ref: '#/components/messages/groupMarked' - - $ref: '#/components/messages/groupOpen' - - $ref: '#/components/messages/groupRename' - - $ref: '#/components/messages/groupUnarchive' - - $ref: '#/components/messages/imClose' - - $ref: '#/components/messages/imCreated' - - $ref: '#/components/messages/imMarked' - - $ref: '#/components/messages/imOpen' - - $ref: '#/components/messages/manualPresenceChange' - - $ref: '#/components/messages/memberJoinedChannel' - - $ref: '#/components/messages/message' - + $ref: '#/components/messages/message' +operations: + receiveOutgoingMessage: + action: receive + channel: + $ref: '#/channels/root' + messages: + - $ref: '#/components/messages/outgoingMessage' + sendMessages: + action: send + channel: + $ref: '#/channels/root' + messages: + - $ref: '#/components/messages/hello' + - $ref: '#/components/messages/connectionError' + - $ref: '#/components/messages/accountsChanged' + - $ref: '#/components/messages/botAdded' + - $ref: '#/components/messages/botChanged' + - $ref: '#/components/messages/channelArchive' + - $ref: '#/components/messages/channelCreated' + - $ref: '#/components/messages/channelDeleted' + - $ref: '#/components/messages/channelHistoryChanged' + - $ref: '#/components/messages/channelJoined' + - $ref: '#/components/messages/channelLeft' + - $ref: '#/components/messages/channelMarked' + - $ref: '#/components/messages/channelRename' + - $ref: '#/components/messages/channelUnarchive' + - $ref: '#/components/messages/commandsChanged' + - $ref: '#/components/messages/dndUpdated' + - $ref: '#/components/messages/dndUpdatedUser' + - $ref: '#/components/messages/emailDomainChanged' + - $ref: '#/components/messages/emojiRemoved' + - $ref: '#/components/messages/emojiAdded' + - $ref: '#/components/messages/fileChange' + - $ref: '#/components/messages/fileCommentAdded' + - $ref: '#/components/messages/fileCommentDeleted' + - $ref: '#/components/messages/fileCommentEdited' + - $ref: '#/components/messages/fileCreated' + - $ref: '#/components/messages/fileDeleted' + - $ref: '#/components/messages/filePublic' + - $ref: '#/components/messages/fileShared' + - $ref: '#/components/messages/fileUnshared' + - $ref: '#/components/messages/goodbye' + - $ref: '#/components/messages/groupArchive' + - $ref: '#/components/messages/groupClose' + - $ref: '#/components/messages/groupHistoryChanged' + - $ref: '#/components/messages/groupJoined' + - $ref: '#/components/messages/groupLeft' + - $ref: '#/components/messages/groupMarked' + - $ref: '#/components/messages/groupOpen' + - $ref: '#/components/messages/groupRename' + - $ref: '#/components/messages/groupUnarchive' + - $ref: '#/components/messages/imClose' + - $ref: '#/components/messages/imCreated' + - $ref: '#/components/messages/imMarked' + - $ref: '#/components/messages/imOpen' + - $ref: '#/components/messages/manualPresenceChange' + - $ref: '#/components/messages/memberJoinedChannel' + - $ref: '#/components/messages/message' components: securitySchemes: token: type: httpApiKey name: token in: query - schemas: attachment: type: object @@ -123,10 +222,9 @@ components: format: uri ts: type: number - messages: hello: - summary: 'First event received upon connection.' + summary: First event received upon connection. payload: type: object properties: @@ -135,7 +233,7 @@ components: enum: - hello connectionError: - summary: 'Event received when a connection error happens.' + summary: Event received when a connection error happens. payload: type: object properties: @@ -151,7 +249,7 @@ components: msg: type: string accountsChanged: - summary: 'The list of accounts a user is signed into has changed.' + summary: The list of accounts a user is signed into has changed. payload: type: object properties: @@ -160,7 +258,7 @@ components: enum: - accounts_changed botAdded: - summary: 'A bot user was added.' + summary: A bot user was added. payload: type: object properties: @@ -182,7 +280,7 @@ components: additionalProperties: type: string botChanged: - summary: 'A bot user was changed.' + summary: A bot user was changed. payload: type: object properties: @@ -204,7 +302,7 @@ components: additionalProperties: type: string channelArchive: - summary: 'A channel was archived.' + summary: A channel was archived. payload: type: object properties: @@ -217,7 +315,7 @@ components: user: type: string channelCreated: - summary: 'A channel was created.' + summary: A channel was created. payload: type: object properties: @@ -237,7 +335,7 @@ components: creator: type: string channelDeleted: - summary: 'A channel was deleted.' + summary: A channel was deleted. payload: type: object properties: @@ -248,7 +346,7 @@ components: channel: type: string channelHistoryChanged: - summary: 'Bulk updates were made to a channel''s history.' + summary: Bulk updates were made to a channel's history. payload: type: object properties: @@ -263,7 +361,7 @@ components: event_ts: type: string channelJoined: - summary: 'You joined a channel.' + summary: You joined a channel. payload: type: object properties: @@ -283,7 +381,7 @@ components: creator: type: string channelLeft: - summary: 'You left a channel.' + summary: You left a channel. payload: type: object properties: @@ -294,7 +392,7 @@ components: channel: type: string channelMarked: - summary: 'Your channel read marker was updated.' + summary: Your channel read marker was updated. payload: type: object properties: @@ -307,7 +405,7 @@ components: ts: type: string channelRename: - summary: 'A channel was renamed.' + summary: A channel was renamed. payload: type: object properties: @@ -325,7 +423,7 @@ components: created: type: number channelUnarchive: - summary: 'A channel was unarchived.' + summary: A channel was unarchived. payload: type: object properties: @@ -338,7 +436,7 @@ components: user: type: string commandsChanged: - summary: 'A slash command has been added or changed.' + summary: A slash command has been added or changed. payload: type: object properties: @@ -349,7 +447,7 @@ components: event_ts: type: string dndUpdated: - summary: 'Do not Disturb settings changed for the current user.' + summary: Do not Disturb settings changed for the current user. payload: type: object properties: @@ -373,7 +471,7 @@ components: snooze_endtime: type: number dndUpdatedUser: - summary: 'Do not Disturb settings changed for a member.' + summary: Do not Disturb settings changed for a member. payload: type: object properties: @@ -393,7 +491,7 @@ components: next_dnd_end_ts: type: number emailDomainChanged: - summary: 'The workspace email domain has changed.' + summary: The workspace email domain has changed. payload: type: object properties: @@ -406,7 +504,7 @@ components: event_ts: type: string emojiRemoved: - summary: 'A custom emoji has been removed.' + summary: A custom emoji has been removed. payload: type: object properties: @@ -425,7 +523,7 @@ components: event_ts: type: string emojiAdded: - summary: 'A custom emoji has been added.' + summary: A custom emoji has been added. payload: type: object properties: @@ -445,7 +543,7 @@ components: event_ts: type: string fileChange: - summary: 'A file was changed.' + summary: A file was changed. payload: type: object properties: @@ -461,7 +559,7 @@ components: id: type: string fileCommentAdded: - summary: 'A file comment was added.' + summary: A file comment was added. payload: type: object properties: @@ -478,7 +576,7 @@ components: id: type: string fileCommentDeleted: - summary: 'A file comment was deleted.' + summary: A file comment was deleted. payload: type: object properties: @@ -496,7 +594,7 @@ components: id: type: string fileCommentEdited: - summary: 'A file comment was edited.' + summary: A file comment was edited. payload: type: object properties: @@ -513,7 +611,7 @@ components: id: type: string fileCreated: - summary: 'A file was created.' + summary: A file was created. payload: type: object properties: @@ -529,7 +627,7 @@ components: id: type: string fileDeleted: - summary: 'A file was deleted.' + summary: A file was deleted. payload: type: object properties: @@ -542,7 +640,7 @@ components: event_ts: type: string filePublic: - summary: 'A file was made public.' + summary: A file was made public. payload: type: object properties: @@ -558,7 +656,7 @@ components: id: type: string fileShared: - summary: 'A file was shared.' + summary: A file was shared. payload: type: object properties: @@ -574,7 +672,7 @@ components: id: type: string fileUnshared: - summary: 'A file was unshared.' + summary: A file was unshared. payload: type: object properties: @@ -590,7 +688,7 @@ components: id: type: string goodbye: - summary: 'The server intends to close the connection soon.' + summary: The server intends to close the connection soon. payload: type: object properties: @@ -599,7 +697,7 @@ components: enum: - goodbye groupArchive: - summary: 'A private channel was archived.' + summary: A private channel was archived. payload: type: object properties: @@ -610,7 +708,7 @@ components: channel: type: string groupClose: - summary: 'You closed a private channel.' + summary: You closed a private channel. payload: type: object properties: @@ -623,7 +721,7 @@ components: channel: type: string groupHistoryChanged: - summary: 'Bulk updates were made to a private channel''s history.' + summary: Bulk updates were made to a private channel's history. payload: type: object properties: @@ -638,7 +736,7 @@ components: event_ts: type: string groupJoined: - summary: 'You joined a private channel.' + summary: You joined a private channel. payload: type: object properties: @@ -658,7 +756,7 @@ components: creator: type: string groupLeft: - summary: 'You left a private channel.' + summary: You left a private channel. payload: type: object properties: @@ -669,7 +767,7 @@ components: channel: type: string groupMarked: - summary: 'A private channel read marker was updated.' + summary: A private channel read marker was updated. payload: type: object properties: @@ -682,7 +780,7 @@ components: ts: type: string groupOpen: - summary: 'You opened a private channel.' + summary: You opened a private channel. payload: type: object properties: @@ -695,7 +793,7 @@ components: channel: type: string groupRename: - summary: 'A private channel was renamed.' + summary: A private channel was renamed. payload: type: object properties: @@ -713,7 +811,7 @@ components: created: type: number groupUnarchive: - summary: 'A private channel was unarchived.' + summary: A private channel was unarchived. payload: type: object properties: @@ -726,7 +824,7 @@ components: user: type: string imClose: - summary: 'You closed a DM.' + summary: You closed a DM. payload: type: object properties: @@ -739,7 +837,7 @@ components: user: type: string imCreated: - summary: 'A DM was created.' + summary: A DM was created. payload: type: object properties: @@ -761,7 +859,7 @@ components: user: type: string imMarked: - summary: 'A direct message read marker was updated.' + summary: A direct message read marker was updated. payload: type: object properties: @@ -774,7 +872,7 @@ components: ts: type: string imOpen: - summary: 'You opened a DM.' + summary: You opened a DM. payload: type: object properties: @@ -787,7 +885,7 @@ components: user: type: string manualPresenceChange: - summary: 'You manually updated your presence.' + summary: You manually updated your presence. payload: type: object properties: @@ -798,7 +896,7 @@ components: presence: type: string memberJoinedChannel: - summary: 'A user joined a public or private channel.' + summary: A user joined a public or private channel. payload: type: object properties: @@ -820,7 +918,7 @@ components: inviter: type: string memberLeftChannel: - summary: 'A user left a public or private channel.' + summary: A user left a public or private channel. payload: type: object properties: @@ -840,7 +938,7 @@ components: team: type: string message: - summary: 'A message was sent to a channel.' + summary: A message was sent to a channel. payload: type: object properties: @@ -868,7 +966,7 @@ components: ts: type: string outgoingMessage: - summary: 'A message was sent to a channel.' + summary: A message was sent to a channel. payload: type: object properties: diff --git a/apps/studio/src/examples/simple.yml b/apps/studio/src/examples/simple.yml index fbb3f891b..f724c8b08 100644 --- a/apps/studio/src/examples/simple.yml +++ b/apps/studio/src/examples/simple.yml @@ -1,13 +1,21 @@ -asyncapi: '2.6.0' +asyncapi: 3.0.0 info: title: Account Service version: 1.0.0 description: This service is in charge of processing user signups channels: - user/signedup: - subscribe: - message: + userSignedup: + address: user/signedup + messages: + UserSignedUp: $ref: '#/components/messages/UserSignedUp' +operations: + sendUserSignedup: + action: send + channel: + $ref: '#/channels/userSignedup' + messages: + - $ref: '#/components/messages/UserSignedUp' components: messages: UserSignedUp: diff --git a/apps/studio/src/examples/streetlights-kafka.yml b/apps/studio/src/examples/streetlights-kafka.yml index 599b5a25d..81312bfb6 100644 --- a/apps/studio/src/examples/streetlights-kafka.yml +++ b/apps/studio/src/examples/streetlights-kafka.yml @@ -1,87 +1,124 @@ -asyncapi: '2.6.0' +asyncapi: 3.0.0 info: title: Streetlights Kafka API - version: '1.0.0' - description: | - The Smartylighting Streetlights API allows you to remotely manage the city lights. - - ### Check out its awesome features: - - * Turn a specific streetlight on/off 🌃 - * Dim a specific streetlight 😎 - * Receive real-time information about environmental lighting conditions 📈 + version: 1.0.0 + description: "The Smartylighting Streetlights API allows you to remotely manage the city lights.\n\n### Check out its awesome features:\n\n* Turn a specific streetlight on/off \U0001F303\n* Dim a specific streetlight \U0001F60E\n* Receive real-time information about environmental lighting conditions \U0001F4C8\n" license: name: Apache 2.0 - url: https://www.apache.org/licenses/LICENSE-2.0 - + url: 'https://www.apache.org/licenses/LICENSE-2.0' +defaultContentType: application/json servers: - test: - url: test.mykafkacluster.org:8092 + scram-connections: + host: 'test.mykafkacluster.org:18092' protocol: kafka-secure - description: Test broker + description: Test broker secured with scramSha256 security: - - saslScram: [] - -defaultContentType: application/json - + - $ref: '#/components/securitySchemes/saslScram' + tags: + - name: 'env:test-scram' + description: >- + This environment is meant for running internal tests through + scramSha256 + - name: 'kind:remote' + description: This server is a remote server. Not exposed by the application + - name: 'visibility:private' + description: This resource is private and only available to certain users + mtls-connections: + host: 'test.mykafkacluster.org:28092' + protocol: kafka-secure + description: Test broker secured with X509 + security: + - $ref: '#/components/securitySchemes/certs' + tags: + - name: 'env:test-mtls' + description: This environment is meant for running internal tests through mtls + - name: 'kind:remote' + description: This server is a remote server. Not exposed by the application + - name: 'visibility:private' + description: This resource is private and only available to certain users channels: - smartylighting.streetlights.1.0.event.{streetlightId}.lighting.measured: + lightingMeasured: + address: 'smartylighting.streetlights.1.0.event.{streetlightId}.lighting.measured' + messages: + lightMeasured: + $ref: '#/components/messages/lightMeasured' description: The topic on which measured values may be produced and consumed. parameters: streetlightId: $ref: '#/components/parameters/streetlightId' - publish: - summary: Inform about environmental lighting conditions of a particular streetlight. - operationId: receiveLightMeasurement - traits: - - $ref: '#/components/operationTraits/kafka' - message: - $ref: '#/components/messages/lightMeasured' - - smartylighting.streetlights.1.0.action.{streetlightId}.turn.on: + lightTurnOn: + address: 'smartylighting.streetlights.1.0.action.{streetlightId}.turn.on' + messages: + turnOn: + $ref: '#/components/messages/turnOnOff' parameters: streetlightId: $ref: '#/components/parameters/streetlightId' - subscribe: - operationId: turnOn - traits: - - $ref: '#/components/operationTraits/kafka' - message: + lightTurnOff: + address: 'smartylighting.streetlights.1.0.action.{streetlightId}.turn.off' + messages: + turnOff: $ref: '#/components/messages/turnOnOff' - - smartylighting.streetlights.1.0.action.{streetlightId}.turn.off: parameters: streetlightId: $ref: '#/components/parameters/streetlightId' - subscribe: - operationId: turnOff - traits: - - $ref: '#/components/operationTraits/kafka' - message: - $ref: '#/components/messages/turnOnOff' - - smartylighting.streetlights.1.0.action.{streetlightId}.dim: + lightsDim: + address: 'smartylighting.streetlights.1.0.action.{streetlightId}.dim' + messages: + dimLight: + $ref: '#/components/messages/dimLight' parameters: streetlightId: $ref: '#/components/parameters/streetlightId' - subscribe: - operationId: dimLight - traits: - - $ref: '#/components/operationTraits/kafka' - message: - $ref: '#/components/messages/dimLight' - +operations: + receiveLightMeasurement: + action: receive + channel: + $ref: '#/channels/lightingMeasured' + summary: >- + Inform about environmental lighting conditions of a particular + streetlight. + traits: + - $ref: '#/components/operationTraits/kafka' + messages: + - $ref: '#/components/messages/lightMeasured' + turnOn: + action: send + channel: + $ref: '#/channels/lightTurnOn' + traits: + - $ref: '#/components/operationTraits/kafka' + messages: + - $ref: '#/components/messages/turnOnOff' + turnOff: + action: send + channel: + $ref: '#/channels/lightTurnOff' + traits: + - $ref: '#/components/operationTraits/kafka' + messages: + - $ref: '#/components/messages/turnOnOff' + dimLight: + action: send + channel: + $ref: '#/channels/lightsDim' + traits: + - $ref: '#/components/operationTraits/kafka' + messages: + - $ref: '#/components/messages/dimLight' components: messages: lightMeasured: name: lightMeasured title: Light measured - summary: Inform about environmental lighting conditions of a particular streetlight. + summary: >- + Inform about environmental lighting conditions of a particular + streetlight. contentType: application/json traits: - $ref: '#/components/messageTraits/commonHeaders' payload: - $ref: "#/components/schemas/lightMeasuredPayload" + $ref: '#/components/schemas/lightMeasuredPayload' turnOnOff: name: turnOnOff title: Turn on/off @@ -89,7 +126,7 @@ components: traits: - $ref: '#/components/messageTraits/commonHeaders' payload: - $ref: "#/components/schemas/turnOnOffPayload" + $ref: '#/components/schemas/turnOnOffPayload' dimLight: name: dimLight title: Dim light @@ -97,8 +134,7 @@ components: traits: - $ref: '#/components/messageTraits/commonHeaders' payload: - $ref: "#/components/schemas/dimLightPayload" - + $ref: '#/components/schemas/dimLightPayload' schemas: lightMeasuredPayload: type: object @@ -108,18 +144,18 @@ components: minimum: 0 description: Light intensity measured in lumens. sentAt: - $ref: "#/components/schemas/sentAt" + $ref: '#/components/schemas/sentAt' turnOnOffPayload: type: object properties: command: type: string enum: - - on - - off + - 'on' + - 'off' description: Whether to turn on or off the light. sentAt: - $ref: "#/components/schemas/sentAt" + $ref: '#/components/schemas/sentAt' dimLightPayload: type: object properties: @@ -129,23 +165,21 @@ components: minimum: 0 maximum: 100 sentAt: - $ref: "#/components/schemas/sentAt" + $ref: '#/components/schemas/sentAt' sentAt: type: string format: date-time description: Date and time when the message was sent. - securitySchemes: saslScram: type: scramSha256 description: Provide your username and password for SASL/SCRAM authentication - + certs: + type: X509 + description: Download the certificate files from service provider parameters: streetlightId: description: The ID of the streetlight. - schema: - type: string - messageTraits: commonHeaders: headers: @@ -155,9 +189,11 @@ components: type: integer minimum: 0 maximum: 100 - operationTraits: kafka: bindings: kafka: - clientId: my-app-id + clientId: + type: string + enum: + - my-app-id \ No newline at end of file diff --git a/apps/studio/src/examples/streetlights-mqtt.yml b/apps/studio/src/examples/streetlights-mqtt.yml index cdb39c5a6..a69742f33 100644 --- a/apps/studio/src/examples/streetlights-mqtt.yml +++ b/apps/studio/src/examples/streetlights-mqtt.yml @@ -1,22 +1,15 @@ -asyncapi: '2.6.0' +asyncapi: 3.0.0 info: title: Streetlights MQTT API - version: '1.0.0' - description: | - The Smartylighting Streetlights API allows you to remotely manage the city lights. - - ### Check out its awesome features: - - * Turn a specific streetlight on/off 🌃 - * Dim a specific streetlight 😎 - * Receive real-time information about environmental lighting conditions 📈 + version: 1.0.0 + description: "The Smartylighting Streetlights API allows you to remotely manage the city lights.\n\n### Check out its awesome features:\n\n* Turn a specific streetlight on/off \U0001F303\n* Dim a specific streetlight \U0001F60E\n* Receive real-time information about environmental lighting conditions \U0001F4C8\n" license: name: Apache 2.0 - url: https://www.apache.org/licenses/LICENSE-2.0 - + url: 'https://www.apache.org/licenses/LICENSE-2.0' +defaultContentType: application/json servers: production: - url: test.mosquitto.org:{port} + host: 'test.mosquitto.org:{port}' protocol: mqtt description: Test broker variables: @@ -27,73 +20,131 @@ servers: - '1883' - '8883' security: - - apiKey: [] - - supportedOauthFlows: - - streetlights:on - - streetlights:off - - streetlights:dim - - openIdConnectWellKnown: [] - -defaultContentType: application/json - + - $ref: '#/components/securitySchemes/apiKey' + - type: oauth2 + description: Flows to support OAuth 2.0 + flows: + implicit: + authorizationUrl: 'https://authserver.example/auth' + availableScopes: + 'streetlights:on': Ability to switch lights on + 'streetlights:off': Ability to switch lights off + 'streetlights:dim': Ability to dim the lights + password: + tokenUrl: 'https://authserver.example/token' + availableScopes: + 'streetlights:on': Ability to switch lights on + 'streetlights:off': Ability to switch lights off + 'streetlights:dim': Ability to dim the lights + clientCredentials: + tokenUrl: 'https://authserver.example/token' + availableScopes: + 'streetlights:on': Ability to switch lights on + 'streetlights:off': Ability to switch lights off + 'streetlights:dim': Ability to dim the lights + authorizationCode: + authorizationUrl: 'https://authserver.example/auth' + tokenUrl: 'https://authserver.example/token' + refreshUrl: 'https://authserver.example/refresh' + availableScopes: + 'streetlights:on': Ability to switch lights on + 'streetlights:off': Ability to switch lights off + 'streetlights:dim': Ability to dim the lights + scopes: + - 'streetlights:on' + - 'streetlights:off' + - 'streetlights:dim' + - $ref: '#/components/securitySchemes/openIdConnectWellKnown' + tags: + - name: 'env:production' + description: This environment is meant for production use case + - name: 'kind:remote' + description: This server is a remote server. Not exposed by the application + - name: 'visibility:public' + description: This resource is public and available to everyone channels: - smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured: + lightingMeasured: + address: 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured' + messages: + lightMeasured: + $ref: '#/components/messages/lightMeasured' description: The topic on which measured values may be produced and consumed. parameters: streetlightId: $ref: '#/components/parameters/streetlightId' - publish: - summary: Inform about environmental lighting conditions of a particular streetlight. - operationId: receiveLightMeasurement - traits: - - $ref: '#/components/operationTraits/mqtt' - message: - $ref: '#/components/messages/lightMeasured' - - smartylighting/streetlights/1/0/action/{streetlightId}/turn/on: + lightTurnOn: + address: 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on' + messages: + turnOn: + $ref: '#/components/messages/turnOnOff' parameters: streetlightId: $ref: '#/components/parameters/streetlightId' - subscribe: - operationId: turnOn - traits: - - $ref: '#/components/operationTraits/mqtt' - message: + lightTurnOff: + address: 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/off' + messages: + turnOff: $ref: '#/components/messages/turnOnOff' - - smartylighting/streetlights/1/0/action/{streetlightId}/turn/off: parameters: streetlightId: $ref: '#/components/parameters/streetlightId' - subscribe: - operationId: turnOff - traits: - - $ref: '#/components/operationTraits/mqtt' - message: - $ref: '#/components/messages/turnOnOff' - - smartylighting/streetlights/1/0/action/{streetlightId}/dim: + lightsDim: + address: 'smartylighting/streetlights/1/0/action/{streetlightId}/dim' + messages: + dimLight: + $ref: '#/components/messages/dimLight' parameters: streetlightId: $ref: '#/components/parameters/streetlightId' - subscribe: - operationId: dimLight - traits: - - $ref: '#/components/operationTraits/mqtt' - message: - $ref: '#/components/messages/dimLight' - +operations: + receiveLightMeasurement: + action: receive + channel: + $ref: '#/channels/lightingMeasured' + summary: >- + Inform about environmental lighting conditions of a particular + streetlight. + traits: + - $ref: '#/components/operationTraits/mqtt' + messages: + - $ref: '#/components/messages/lightMeasured' + turnOn: + action: send + channel: + $ref: '#/channels/lightTurnOn' + traits: + - $ref: '#/components/operationTraits/mqtt' + messages: + - $ref: '#/components/messages/turnOnOff' + turnOff: + action: send + channel: + $ref: '#/channels/lightTurnOff' + traits: + - $ref: '#/components/operationTraits/mqtt' + messages: + - $ref: '#/components/messages/turnOnOff' + dimLight: + action: send + channel: + $ref: '#/channels/lightsDim' + traits: + - $ref: '#/components/operationTraits/mqtt' + messages: + - $ref: '#/components/messages/dimLight' components: messages: lightMeasured: name: lightMeasured title: Light measured - summary: Inform about environmental lighting conditions of a particular streetlight. + summary: >- + Inform about environmental lighting conditions of a particular + streetlight. contentType: application/json traits: - $ref: '#/components/messageTraits/commonHeaders' payload: - $ref: "#/components/schemas/lightMeasuredPayload" + $ref: '#/components/schemas/lightMeasuredPayload' turnOnOff: name: turnOnOff title: Turn on/off @@ -101,7 +152,7 @@ components: traits: - $ref: '#/components/messageTraits/commonHeaders' payload: - $ref: "#/components/schemas/turnOnOffPayload" + $ref: '#/components/schemas/turnOnOffPayload' dimLight: name: dimLight title: Dim light @@ -109,8 +160,7 @@ components: traits: - $ref: '#/components/messageTraits/commonHeaders' payload: - $ref: "#/components/schemas/dimLightPayload" - + $ref: '#/components/schemas/dimLightPayload' schemas: lightMeasuredPayload: type: object @@ -120,18 +170,18 @@ components: minimum: 0 description: Light intensity measured in lumens. sentAt: - $ref: "#/components/schemas/sentAt" + $ref: '#/components/schemas/sentAt' turnOnOffPayload: type: object properties: command: type: string enum: - - on - - off + - 'on' + - 'off' description: Whether to turn on or off the light. sentAt: - $ref: "#/components/schemas/sentAt" + $ref: '#/components/schemas/sentAt' dimLightPayload: type: object properties: @@ -141,12 +191,11 @@ components: minimum: 0 maximum: 100 sentAt: - $ref: "#/components/schemas/sentAt" + $ref: '#/components/schemas/sentAt' sentAt: type: string format: date-time description: Date and time when the message was sent. - securitySchemes: apiKey: type: apiKey @@ -158,19 +207,19 @@ components: flows: implicit: authorizationUrl: 'https://authserver.example/auth' - scopes: + availableScopes: 'streetlights:on': Ability to switch lights on 'streetlights:off': Ability to switch lights off 'streetlights:dim': Ability to dim the lights password: tokenUrl: 'https://authserver.example/token' - scopes: + availableScopes: 'streetlights:on': Ability to switch lights on 'streetlights:off': Ability to switch lights off 'streetlights:dim': Ability to dim the lights clientCredentials: tokenUrl: 'https://authserver.example/token' - scopes: + availableScopes: 'streetlights:on': Ability to switch lights on 'streetlights:off': Ability to switch lights off 'streetlights:dim': Ability to dim the lights @@ -178,20 +227,16 @@ components: authorizationUrl: 'https://authserver.example/auth' tokenUrl: 'https://authserver.example/token' refreshUrl: 'https://authserver.example/refresh' - scopes: + availableScopes: 'streetlights:on': Ability to switch lights on 'streetlights:off': Ability to switch lights off 'streetlights:dim': Ability to dim the lights openIdConnectWellKnown: type: openIdConnect openIdConnectUrl: 'https://authserver.example/.well-known' - parameters: streetlightId: description: The ID of the streetlight. - schema: - type: string - messageTraits: commonHeaders: headers: @@ -201,7 +246,6 @@ components: type: integer minimum: 0 maximum: 100 - operationTraits: mqtt: bindings: diff --git a/apps/studio/src/examples/websocket-gemini.yml b/apps/studio/src/examples/websocket-gemini.yml index b799c1c56..ca38221d5 100644 --- a/apps/studio/src/examples/websocket-gemini.yml +++ b/apps/studio/src/examples/websocket-gemini.yml @@ -1,83 +1,137 @@ -# -# -# -# This example showcases usage of AsyncAPI for the purpose of describing a WebSocket API. It is based on a real public service maintained by company called Gemini that provides cryptocurency trading products. It uses AsyncAPI bindings. -# -# This AsyncAPI document describes their v1 of the API. The v2 is also available and changes in the way that it provides a multimessage channel, where you subscribe for messages by sending a subscription message instead of using query parameters. For example with multimessage channel check out this article https://www.asyncapi.com/blog/websocket-part2 about another real public API called Kraken -# -# All available learning materials about AsyncAPI and WebSocket are: -# - WebSocket, Shrek, and AsyncAPI - An Opinionated Intro article: https://www.asyncapi.com/blog/websocket-part1 -# - Creating AsyncAPI for WebSocket API - Step by Step article: https://www.asyncapi.com/blog/websocket-part2 -# - From API-First to Code Generation - A WebSocket Use Case article: https://www.asyncapi.com/blog/websocket-part3 -# - Live stream about topics mentioned in part 1 and 2 articles: https://www.youtube.com/watch?v=8tFBcf31e_c -# - -asyncapi: '2.6.0' - -# -# Overal information for users of the application -# +asyncapi: 3.0.0 info: title: Gemini Market Data Websocket API - version: '1.0.0' - contact: - name: Gemini - url: https://www.gemini.com/ - description: | - Market data is a public API that streams all the market data on a given symbol. - - You can quickly play with the API using [websocat](https://github.com/vi/websocat#installation) like this: + version: 1.0.0 + description: > + Market data is a public API that streams all the market data on a given + symbol. + + + You can quickly play with the API using + [websocat](https://github.com/vi/websocat#installation) like this: + ```bash + websocat wss://api.gemini.com/v1/marketdata/btcusd?heartbeat=true -S + ``` - -# -# Link to external docs -# -externalDocs: - url: https://docs.sandbox.gemini.com/websocket-api/#market-data - -# -# Details on how to connect to the application -# + contact: + name: Gemini + url: 'https://www.gemini.com/' + externalDocs: + url: 'https://docs.sandbox.gemini.com/websocket-api/#market-data' servers: public: - url: wss://api.gemini.com + host: api.gemini.com protocol: wss - -# -# Details about all the channels that you can listen to or send to messages -# channels: - /v1/marketdata/{symbol}: + marketDataV1: + address: '/v1/marketdata/{symbol}' + messages: + marketData: + $ref: '#/components/messages/marketData' parameters: symbol: - description: | - Symbols are formatted as CCY1CCY2 where prices are in CCY2 and quantities are in CCY1. To read more click [here](https://docs.sandbox.gemini.com/websocket-api/#symbols-and-minimums). - schema: - type: string - enum: ['btcusd', 'ethbtc', 'ethusd', 'zecusd', 'zecbtc', 'zeceth', 'zecbch', 'zecltc', 'bchusd', 'bchbtc', 'bcheth', 'ltcusd', 'ltcbtc', 'ltceth', 'ltcbch', 'batusd', 'daiusd', 'linkusd', 'oxtusd', 'batbtc', 'linkbtc', 'oxtbtc', 'bateth', 'linketh', 'oxteth', 'ampusd', 'compusd', 'paxgusd', 'mkrusd', 'zrxusd', 'kncusd', 'manausd', 'storjusd', 'snxusd', 'crvusd', 'balusd', 'uniusd', 'renusd', 'umausd', 'yfiusd', 'btcdai', 'ethdai', 'aaveusd', 'filusd', 'btceur', 'btcgbp', 'etheur', 'ethgbp', 'btcsgd', 'ethsgd', 'sklusd', 'grtusd', 'bntusd', '1inchusd', 'enjusd', 'lrcusd', 'sandusd', 'cubeusd', 'lptusd', 'bondusd', 'maticusd', 'injusd', 'sushiusd'] + enum: + - btcusd + - ethbtc + - ethusd + - zecusd + - zecbtc + - zeceth + - zecbch + - zecltc + - bchusd + - bchbtc + - bcheth + - ltcusd + - ltcbtc + - ltceth + - ltcbch + - batusd + - daiusd + - linkusd + - oxtusd + - batbtc + - linkbtc + - oxtbtc + - bateth + - linketh + - oxteth + - ampusd + - compusd + - paxgusd + - mkrusd + - zrxusd + - kncusd + - manausd + - storjusd + - snxusd + - crvusd + - balusd + - uniusd + - renusd + - umausd + - yfiusd + - btcdai + - ethdai + - aaveusd + - filusd + - btceur + - btcgbp + - etheur + - ethgbp + - btcsgd + - ethsgd + - sklusd + - grtusd + - bntusd + - 1inchusd + - enjusd + - lrcusd + - sandusd + - cubeusd + - lptusd + - bondusd + - maticusd + - injusd + - sushiusd + description: > + Symbols are formatted as CCY1CCY2 where prices are in CCY2 and + quantities are in CCY1. To read more click + [here](https://docs.sandbox.gemini.com/websocket-api/#symbols-and-minimums). bindings: ws: bindingVersion: 0.1.0 query: type: object - description: | + description: > The semantics of entry type filtering is: - If any entry type is specified as true or false, all of them must be explicitly flagged true to show up in the response - If no entry types filtering parameters are included in the url, then all entry types will appear in the response - NOTE: top_of_book has no meaning and initial book events are empty when only trades is specified + If any entry type is specified as true or false, all of them must be + explicitly flagged true to show up in the response + + If no entry types filtering parameters are included in the url, then + all entry types will appear in the response + + + NOTE: top_of_book has no meaning and initial book events are empty + when only trades is specified properties: heartbeat: type: boolean default: false - description: Optionally add this parameter and set to true to receive a heartbeat every 5 seconds + description: >- + Optionally add this parameter and set to true to receive a + heartbeat every 5 seconds top_of_book: type: boolean default: false - description: If absent or false, receive full order book depth; if present and true, receive top of book only. Only applies to bids and offers. + description: >- + If absent or false, receive full order book depth; if present + and true, receive top of book only. Only applies to bids and + offers. bids: type: boolean default: true @@ -94,40 +148,44 @@ channels: type: boolean default: true description: Include auction events - subscribe: - summary: Receive market updates on a given symbol - message: - $ref: '#/components/messages/marketData' - -# -# All reusable parts for readability and staying DRY -# +operations: + sendMarketData: + action: send + channel: + $ref: '#/channels/marketDataV1' + summary: Receive market updates on a given symbol + messages: + - $ref: '#/components/messages/marketData' components: messages: marketData: summary: Message with marked data information. - description: | - The initial response message will show the existing state of the order book. Subsequent messages will show all executed trades, as well as all other changes to the order book from orders placed or canceled. + description: > + The initial response message will show the existing state of the order + book. Subsequent messages will show all executed trades, as well as all + other changes to the order book from orders placed or canceled. payload: $ref: '#/components/schemas/market' examples: - name: updateMessage - summary: Example of an update message that contains a change in price information. + summary: >- + Example of an update message that contains a change in price + information. payload: type: update eventId: 36902233362 - timestamp: 1619769673 - timestampms: 1619769673527 + timestamp: '1619769673' + timestampms: '1619769673527' socket_sequence: 661 events: - type: change side: bid - price: 54350.40 - remaining: 0.002 - delta: 0.002 + price: '54350.40' + remaining: '0.002' + delta: '0.002' reason: place - name: heartbeatMessage - summary: Example of additional heartbeat message when you enable them. + summary: Example of additional heartbeat message when you enable them. payload: type: heartbeat socket_sequence: 1656 @@ -154,14 +212,22 @@ components: const: update eventId: type: integer - description: A monotonically increasing sequence number indicating when this change occurred. These numbers are persistent and consistent between market data connections. + description: >- + A monotonically increasing sequence number indicating when this + change occurred. These numbers are persistent and consistent + between market data connections. events: $ref: '#/components/schemas/events' timestamp: - type: number - description: The timestamp in seconds for this group of events (included for compatibility reasons). We recommend using the timestampms field instead. + type: string + format: date-time + description: >- + The timestamp in seconds for this group of events (included for + compatibility reasons). We recommend using the timestampms field + instead. timestampms: - type: number + type: string + format: time description: The timestamp in milliseconds for this group of events. required: - type @@ -172,38 +238,68 @@ components: - $ref: '#/components/schemas/default' default: type: object - description: This object is always part of the payload. In case of type=heartbeat, these are the only fields. + description: >- + This object is always part of the payload. In case of type=heartbeat, + these are the only fields. required: - - type - - socket_sequence + - type + - socket_sequence properties: socket_sequence: type: integer - description: zero-indexed monotonic increasing sequence number attached to each message sent - if there is a gap in this sequence, you have missed a message. If you choose to enable heartbeats, then heartbeat and update messages will share a single increasing sequence. See [Sequence Numbers](https://docs.sandbox.gemini.com/websocket-api/#sequence-numbers) for more information. + description: >- + zero-indexed monotonic increasing sequence number attached to each + message sent - if there is a gap in this sequence, you have missed a + message. If you choose to enable heartbeats, then heartbeat and + update messages will share a single increasing sequence. See + [Sequence + Numbers](https://docs.sandbox.gemini.com/websocket-api/#sequence-numbers) + for more information. events: type: array - description: Either a change to the order book, or the indication that a trade has occurred. + description: >- + Either a change to the order book, or the indication that a trade has + occurred. items: type: object additionalProperties: false properties: type: type: string - enum: ['trade', 'change', 'auction, block_trade'] + enum: + - trade + - change + - 'auction, block_trade' price: type: number - multipleOf: 0.01 + multipleOf: 1 description: The price of this order book entry. side: type: string - enum: ['bid', 'side'] + enum: + - bid + - side reason: type: string - enum: ['place', 'trade', 'cancel', 'initial'] - description: Indicates why the change has occurred. initial is for the initial response message, which will show the entire existing state of the order book. - remaining: + enum: + - place + - trade + - cancel + - initial + description: >- + Indicates why the change has occurred. initial is for the initial + response message, which will show the entire existing state of the + order book. + remaining: type: number - description: The quantity remaining at that price level after this change occurred. May be zero if all orders at this price level have been filled or canceled. + multipleOf: 1 + description: >- + The quantity remaining at that price level after this change + occurred. May be zero if all orders at this price level have been + filled or canceled. delta: type: number - description: The quantity changed. May be negative, if an order is filled or canceled. For initial messages, delta will equal remaining. \ No newline at end of file + multipleOf: 1 + description: >- + The quantity changed. May be negative, if an order is filled or + canceled. For initial messages, delta will equal remaining. \ No newline at end of file