diff --git a/examples/adeo-kafka-request-reply.yml b/examples/adeo-kafka-request-reply.yml new file mode 100644 index 000000000..76fca663b --- /dev/null +++ b/examples/adeo-kafka-request-reply.yml @@ -0,0 +1,332 @@ +asyncapi: 3.0.0 +info: + title: Adeo AsyncAPI Case Study + version: "%REPLACED_BY_MAVEN%" + description: > + This Adeo specification illustrates how ADEO uses AsyncAPI to document some of their exchanges + contact: + name: AsyncAPI team + email: info@asyncapi.io +servers: + production: + url: "prod.url:9092" + protocol: kafka-secure + description: Kafka PRODUCTION cluster + security: + - sasl-ssl: [] + bindings: + kafka: + schemaRegistryUrl: >- + https://schema-registry.prod.url/ + staging: + url: "staging.url:9092" + protocol: kafka-secure + description: Kafka STAGING cluster for `uat` and `preprod` environments + security: + - sasl-ssl: [] + bindings: + kafka: + schemaRegistryUrl: >- + https://schema-registry.staging.url/ + dev: + url: "dev.url:9092" + protocol: kafka-secure + description: Kafka DEV cluster for `dev` and `sit` environments + security: + - sasl-ssl: [] + bindings: + kafka: + schemaRegistryUrl: >- + https://schema-registry.dev.url/ +tags: + - name: costing + description: "Costing channels, used by Costing clients." +channels: + costingRequest: + address: "adeo-{env}-case-study-COSTING-REQUEST-{version}" + description: > + Use this topic to do a Costing Request to Costing product. + We use the + [**RecordNameStrategy**](https://docs.confluent.io/platform/current/schema-registry/serdes-develop/index.html#subject-name-strategy) + to infer the messages schema. + You have to define `x-value.subject.name.strategy` to + `io.confluent.kafka.serializers.subject.RecordNameStrategy` in your + producer to use the schema we manage. + The schema below illustrates how Costing Request messages are + handled. + ![](https://user-images.githubusercontent.com/5501911/188920831-689cec5f-8dc3-460b-8794-0b54ec8b0ac8.png) + parameters: + env: + $ref: "#/components/parameters/Env" + version: + $ref: "#/components/parameters/Version" + bindings: + kafka: + replicas: 3 + partitions: 3 + topicConfiguration + cleanup.policy: delete + retention.ms: 7 days + messages: + costingRequest: + $ref: "#/components/messages/costingRequestV1" + + + + + + costingResponse: + address: "adeo-{env}-case-study-COSTING-RESPONSE-{version}" + description: > + This topic is used to REPLY Costing Requests and is targeted by the + `REPLY_TOPIC` header. + **You must grant PUBLISH access to our `svc-ccr-app` service account.**. + We use the + [**RecordNameStrategy**](https://docs.confluent.io/platform/current/schema-registry/serdes-develop/index.html#subject-name-strategy) + to infer the messages schema. + You have to define `key.subject.name.strategy` and + `x-value.subject.name.strategy` to + `io.confluent.kafka.serializers.subject.RecordNameStrategy` in your + consumer. + The schema below illustrates how Costing Response messages are + handled. + ![](https://user-images.githubusercontent.com/5501911/188920831-689cec5f-8dc3-460b-8794-0b54ec8b0ac8.png) + parameters: + env: + $ref: "#/components/parameters/Env" + version: + $ref: "#/components/parameters/Version" + bindings: + kafka: + groupId: + type: string + description: > + The groupId must be prefixed by your `svc` account, deliver by the + Adeo Kafka team. + This `svc` must have the read access to the topic. + x-key.subject.name.strategy: + type: string + description: > + We use the RecordNameStrategy to infer the messages schema. + Use + `x-key.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy` + in your consumer configuration. + x-value.subject.name.strategy: + type: string + description: > + We use the RecordNameStrategy to infer the messages schema. + Use + `x-value.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy` + in your consumer configuration. + messages: + costingResponse: + $ref: "#/components/messages/costingResponse" + + + + + +operations: + requestCosting: + action: receive + channel: + $ref: '#/channels/costingRequest' + reply: + channel: + $ref: '#/channels/costingResponse' + address: + locaton: '$message.header#/REPLY_TOPIC' + summary: | + [COSTING] Request one or more Costing calculation for any product + description: > + You can try a costing request using our [Conduktor producer + template](https://conduktor.url) + tags: + - name: costing + bindings: + kafka: + groupId: + type: string + description: > + The groupId must be prefixed by your `svc` account, deliver by the + Adeo Kafka team. + This `svc` must have the write access to the topic. + x-value.subject.name.strategy: + type: string + description: > + We use the RecordNameStrategy to infer the messages schema. + Use + `x-value.subject.name.strategy=io.confluent.kafka.serializers.subject.RecordNameStrategy` + in your producer configuration. + getCostingResponse: + action: send + channel: + $ref: '#/channels/costingResponse' + summary: > + [COSTING] Get the costing responses matching an initial Costing + Request. + tags: + - name: costing + + + + + +components: + correlationIds: + costingCorrelationId: + description: > + This correlation ID is used for message tracing and messages + correlation. + This correlation ID is generated at runtime based on the `REQUEST_ID` + and sent to the RESPONSE message. + location: $message.header#/REQUEST_ID + messages: + costingRequestV1: + name: CostingRequestV1 + title: Costing Request V1 + summary: Costing Request V1 inputs. + tags: + - name: costing + schemaFormat: application/vnd.apache.avro;version=1.9.0 + correlationId: + $ref: "#/components/correlationIds/costingCorrelationId" + headers: + type: object + required: + - REQUESTER_ID + - REQUESTER_CODE + - REQUEST_ID + - REPLY_TOPIC + properties: + REQUEST_ID: + $ref: "#/components/schemas/RequestId" + REPLY_TOPIC: + $ref: "#/components/schemas/ReplyTopic" + REQUESTER_ID: + $ref: "#/components/schemas/RequesterId" + REQUESTER_CODE: + $ref: "#/components/schemas/RequesterCode" + payload: + $ref: "https://deploy-preview-921--asyncapi-website.netlify.app/resources/casestudies/adeo/CostingRequestPayload.avsc" + costingResponse: + name: CostingResponse + title: Costing Response + summary: Costing Response ouputs. + tags: + - name: costing + description: > + Please refer to the `CostingResponseKey.avsc` schema, available on [our + github + project](https://github.url/). + schemaFormat: application/vnd.apache.avro;version=1.9.0 + correlationId: + $ref: "#/components/correlationIds/costingCorrelationId" + headers: + type: object + properties: + CALCULATION_ID: + $ref: "#/components/schemas/MessageId" + CORRELATION_ID: + $ref: "#/components/schemas/CorrelationId" + REQUEST_TIMESTAMP: + type: string + format: date-time + description: Timestamp of the costing request + CALCULATION_TIMESTAMP: + type: string + format: date-time + description: Technical timestamp for the costing calculation + bindings: + kafka: + key: + $ref: "https://deploy-preview-921--asyncapi-website.netlify.app/resources/casestudies/adeo/CostingResponseKey.avsc" + payload: + $ref: "https://deploy-preview-921--asyncapi-website.netlify.app/resources/casestudies/adeo/CostingResponsePayload.avsc" + schemas: + RequesterId: + type: string + description: The Costing requester service account used to produce costing request. + example: svc-ecollect-app + RequesterCode: + type: string + description: >- + The Costing requester code (generally the BU Code). The requester code + is useful to get the dedicated context (tenant). + example: 1 + MessageId: + type: string + format: uuid + description: A unique Message ID. + example: 1fa6ef40-8f47-40a8-8cf6-f8607d0066ef + RequestId: + type: string + format: uuid + description: >- + A unique Request ID needed to define a `CORRELATION_ID` for exchanges, + which will be sent back in the Costing Responses. + example: 1fa6ef40-8f47-40a8-8cf6-f8607d0066ef + CorrelationId: + type: string + format: uuid + description: >- + A unique Correlation ID defined from the `REQUEST_ID` or the + `MESSAGE_ID` provided in the Costing Request. + example: 1fa6ef40-8f47-40a8-8cf6-f8607d0066ef + BuCode: + type: string + description: The Business Unit code for which data are applicable. + example: 1 + ReplyTopic: + type: string + description: > + The Kafka topic where to send the Costing Response. This is required for + the [Return Address EIP + pattern](https://www.enterpriseintegrationpatterns.com/patterns/messaging/ReturnAddress.html). + **You must grant WRITE access to our `svc-ccr-app` service account.** + example: adeo-case-study-COSTING-RESPONSE-V1 + ErrorStep: + type: string + description: | + The woker that has thrown the error. + example: EXPOSE_RESULT + ErrorMessage: + type: string + description: | + The error message describing the error. + example: Error message + ErrorCode: + type: string + description: | + The error code. + example: CURRENCY_NOT_FOUND + parameters: + Env: + description: Adeo Kafka Environement for messages publications. + schema: + type: string + enum: + - dev + - sit + - uat1 + - preprod + - prod + Version: + description: the topic version you want to use + schema: + type: string + example: V1 + default: V1 + securitySchemes: + sasl-ssl: + type: plain + x-sasl.jaas.config: >- + org.apache.kafka.common.security.plain.PlainLoginModule required + username="" password=""; + x-security.protocol: SASL_SSL + x-ssl.endpoint.identification.algorithm: https + x-sasl.mechanism: PLAIN + description: > + Use [SASL authentication with SSL + encryption](https://docs.confluent.io/platform/current/security/security_tutorial.html#configure-clients) + to connect to the ADEO Broker. \ No newline at end of file diff --git a/examples/kraken-websocket-request-reply-message-filter-in-reply.yml b/examples/kraken-websocket-request-reply-message-filter-in-reply.yml new file mode 100644 index 000000000..f82a7aa93 --- /dev/null +++ b/examples/kraken-websocket-request-reply-message-filter-in-reply.yml @@ -0,0 +1,357 @@ +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' + + +operations: + pingPong: + action: send + channel: + $ref: '#/channels/currencyExchange' + reply: + channel: + $ref: '#/channels/currencyExchange' + messages: + $ref: '#/components/messages/ping' + heartbeat: + action: receive + channel: + $ref: '#/channels/currencyExchange' + systemStatus: + action: receive + channel: + $ref: '#/channels/currencyExchange' + subscribe: + action: send + channel: + $ref: '#/channels/currencyExchange' + reply: + channel: + $ref: '#/channels/currencyExchange' + messages: + $ref: '#/components/messages/subscriptionStatus' + unsubscribe: + action: send + channel: + $ref: '#/channels/currencyExchange' + reply: + channel: + $ref: '#/channels/currencyExchange' + messages: + $ref: '#/components/messages/subscriptionStatus' + + +components: + messages: + 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/examples/kraken-websocket-request-reply-multiple-channels.yml b/examples/kraken-websocket-request-reply-multiple-channels.yml new file mode 100644 index 000000000..4bf3bf570 --- /dev/null +++ b/examples/kraken-websocket-request-reply-multiple-channels.yml @@ -0,0 +1,372 @@ +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: + ping: + address: / + messages: + ping: + $ref: '#/components/messages/ping' + pong: + address: / + messages: + pong: + $ref: '#/components/messages/pong' + + heartbeat: + address: / + messages: + heartbeat: + $ref: '#/components/messages/heartbeat' + + systemStatus: + address: / + messages: + systemStatus: + $ref: '#/components/messages/systemStatus' + + subscriptionStatus: + address: / + messages: + subscriptionStatus: + $ref: '#/components/messages/subscriptionStatus' + subscribe: + address: / + messages: + subscribe: + $ref: '#/components/messages/subscribe' + unsubscribe: + address: / + messages: + unsubscribe: + $ref: '#/components/messages/unsubscribe' + + +operations: + pingPong: + action: send + channel: + $ref: '#/channels/ping' + reply: + channel: + $ref: '#/channels/pong' + heartbeat: + action: receive + channel: + $ref: '#/channels/heartbeat' + systemStatus: + action: receive + channel: + $ref: '#/channels/systemStatus' + subscribe: + action: send + channel: + $ref: '#/channels/subscribe' + reply: + channel: + $ref: '#/channels/subscriptionStatus' + unsubscribe: + action: send + channel: + $ref: '#/channels/unsubscribe' + reply: + channel: + $ref: '#/channels/subscriptionStatus' + + +components: + messages: + 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/spec/asyncapi.md b/spec/asyncapi.md index 4454d3364..d3e603846 100644 --- a/spec/asyncapi.md +++ b/spec/asyncapi.md @@ -95,6 +95,8 @@ Aside from the issues mentioned above, there may also be infrastructure configur - [Operations Object](#operationsObject) - [Operation Object](#operationObject) - [Operation Trait Object](#operationTraitObject) + - [Operation Reply Object](#operationReplyObject) + - [Operation Reply Address Object](#operationReplyAddressObject) - [Message Object](#messageObject) - [Message Trait Object](#messageTraitObject) - [Message Example Object](#messageExampleObject) @@ -836,6 +838,8 @@ Field Name | Type | Description externalDocs | [External Documentation Object](#externalDocumentationObject) \| [Reference Object](#referenceObject) | Additional external documentation for this operation. bindings | [Operation Bindings Object](#operationBindingsObject) \| [Reference Object](#referenceObject) | A map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the operation. traits | [[Operation Trait Object](#operationTraitObject) | [Reference Object](#referenceObject) ] | A list of traits to apply to the operation object. Traits MUST be merged into the operation object using the [JSON Merge Patch](https://tools.ietf.org/html/rfc7386) algorithm in the same order they are defined here. +messages | [[Reference Object](#referenceObject)] | A list of `$ref` pointers pointing to the supported [Message Objects](#messageObject) that can be processed by this operation. It MUST contain a subset of the messages defined in the [channel referenced in this operation](#operationObjectChannel). **Every message processed by this operation MUST be valid against one, and only one, of the [message objects](#messageObject) referenced in this list.** Please note the `messages` property value MUST be a list of [Reference Objects](#referenceObject) and, therefore, MUST NOT contain [Message Objects](#messageObject). However, it is RECOMMENDED that parsers (or other software) dereference this property for a better development experience. +reply | [Operation Reply Object](#operationReplyObject) | [Reference Object](#referenceObject) | The definition of the reply in a request-reply operation. This object MAY be extended with [Specification Extensions](#specificationExtensions). @@ -870,7 +874,21 @@ This object MAY be extended with [Specification Extensions](#specificationExtens }, "traits": [ { "$ref": "#/components/operationTraits/kafka" } - ] + ], + "messages": [ + { "$ref": "/components/messages/userSignedUp" } + ], + "reply": { + "address": { + "location": "$message.header#/replyTo" + }, + "channel": { + "$ref": "#/channels/userSignupReply" + }, + "messages": [ + { "$ref": "/components/messages/userSignedUpReply" } + ], + } } ``` @@ -894,6 +912,15 @@ bindings: ack: false traits: - $ref: "#/components/operationTraits/kafka" +messages: + - $ref: '#/components/messages/userSignedUp' +reply: + address: + location: '$message.header#/replyTo' + channel: + $ref: '#/channels/userSignupReply' + messages: + - $ref: '#/components/messages/userSignedUpReply' ``` @@ -940,6 +967,51 @@ bindings: +#### Operation Reply Object + +Describes the reply part that MAY be applied to an Operation Object. If an operation implements the request/reply pattern, the reply object represents the response message. + +##### Fixed Fields + +Field Name | Type | Description +---|:---:|--- +address | [Operation Reply Address Object](#operationReplyAddressObject) | [Reference Object](#referenceObject) | Definition of the address that implementations MUST use for the reply. +channel | [Reference Object](#referenceObject) | A `$ref` pointer to the definition of the channel in which this operation is performed. When [address](#operationReplyAddressObject) is specified, the [`address` property](#channelObjectAddress) of the channel referenced by this property MUST be either `null` or not defined. Please note the `channel` property value MUST be a [Reference Object](#referenceObject) and, therefore, MUST NOT contain a [Channel Object](#channelObject). However, it is RECOMMENDED that parsers (or other software) dereference this property for a better development experience. +messages | [[Reference Object](#referenceObject)] | A list of `$ref` pointers pointing to the supported [Message Objects](#messageObject) that can be processed by this operation as reply. It MUST contain a subset of the messages defined in the [channel referenced in this operation reply](#operationObjectChannel). **Every message processed by this operation MUST be valid against one, and only one, of the [message objects](#messageObject) referenced in this list.** Please note the `messages` property value MUST be a list of [Reference Objects](#referenceObject) and, therefore, MUST NOT contain [Message Objects](#messageObject). However, it is RECOMMENDED that parsers (or other software) dereference this property for a better development experience. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +#### Operation Reply Address Object + +An object that specifies where an operation has to send the reply. + +For specifying and computing the location of a reply address, a [runtime expression](#runtimeExpression) is used. + + +##### Fixed Fields + +Field Name | Type | Description +---|:---|--- +description | `string` | An optional description of the address. [CommonMark syntax](https://spec.commonmark.org/) can be used for rich text representation. +location | `string` | **REQUIRED.** A [runtime expression](#runtimeExpression) that specifies the location of the reply address. + +This object MAY be extended with [Specification Extensions](#specificationExtensions). + +##### Examples + +```json +{ + "description": "Consumer inbox", + "location": "$message.header#/replyTo" +} +``` + +```yaml +description: Consumer Inbox +location: $message.header#/replyTo +``` + + #### Parameters Object Describes a map of parameters included in a channel name. @@ -1569,6 +1641,8 @@ Field Name | Type | Description serverVariables | Map[`string`, [Server Variable Object](#serverVariableObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Server Variable Objects](#serverVariableObject). parameters | Map[`string`, [Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Parameter Objects](#parameterObject). correlationIds | Map[`string`, [Correlation ID Object](#correlationIdObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Correlation ID Objects](#correlationIdObject). +replies | Map[`string`, [Operation Reply Object](#operationReplyObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Operation Reply Objects](#operationReplyObject). + replyAddresses | Map[`string`, [Operation Reply Address Object](#operationReplyAddressObject) | [Reference Object](#referenceObject)] | An object to hold reusable [Operation Reply Address Objects](#operationReplyAddressObject). externalDocs | Map[`string`, [External Documentation Object](#externalDocumentationObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [External Documentation Objects](#externalDocumentationObject). tags | Map[`string`, [Tag Object](#tagObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Tag Objects](#tagObject). operationTraits | Map[`string`, [Operation Trait Object](#operationTraitObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Operation Trait Objects](#operationTraitObject).