Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Events APIs #74

Merged
merged 1 commit into from
Apr 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ It means [processes](#definitionsProcess) can subscribe to `event.user.signup` t
- [Servers Object](#A2SServers)
- [Topics Object](#topicsObject)
- [Topic Item Object](#topicItemObject)
- [Stream Object](#streamObject)
- [Events Object](#eventsObject)
- [Message Object](#messageObject)
- [Tag Object](#tagObject)
- [External Documentation Object](#externalDocumentationObject)
Expand Down Expand Up @@ -140,8 +142,9 @@ Field Name | Type | Description
<a name="A2SInfo"></a>info | [Info Object](#infoObject) | **Required.** Provides metadata about the API. The metadata can be used by the clients if needed.
<a name="A2SBaseTopic"></a>baseTopic | [BaseTopic String](#baseTopicString) | The base topic to the API.
<a name="A2SServers"></a>servers | [Server Object](#serverObject) | An array of [Server Objects](#serverObject), which provide connectivity information to a target server.
<a name="A2STopics"></a>topics | [Topics Object](#topicsObject) | **Required unless [Stream Object](#streamObject) is provided.** The available topics and messages for the API.
<a name="A2SStream"></a>stream | [Stream Object](#streamObject) | **Required unless [Topics Object](#topicsObject) is provided.** The messages and configuration for the streaming API.
<a name="A2STopics"></a>topics | [Topics Object](#topicsObject) | **Required unless [Stream Object](#streamObject) or [Events Object](#eventsObject) is provided.** The available topics and messages for the API.
<a name="A2SStream"></a>stream | [Stream Object](#streamObject) | **Required unless [Topics Object](#topicsObject) or [Events Object](#eventsObject) is provided.** The messages and configuration for the streaming API.
<a name="A2SEvents"></a>events | [Events Object](#eventsObject) | **Required unless [Topics Object](#topicsObject) or [Stream Object](#streamObject) is provided.** The messages and configuration for the events API.
<a name="A2SComponents"></a>components | [Components Object](#componentsObject) | An element to hold various schemas for the specification.
<a name="A2SSecurity"></a>security | [[Security Requirement Object](#securityRequirementObject)] | A declaration of which security mechanisms can be used across the API. The list of values includes alternative security requirement objects that can be used. Only one of the security requirement objects need to be satisfied to authorize a connection or operation.
<a name="A2STags"></a>tags | [[Tag Object](#tagObject)] | A list of tags used by the specification with additional metadata. Each tag name in the list MUST be unique.
Expand Down Expand Up @@ -682,6 +685,48 @@ framing:




#### <a name="eventsObject"></a>Events Object

Holds the send and receive operations for an API based on events but without topics, e.g., a WebSockets API.

##### Fixed Fields

Field Name | Type | Description
---|:---:|---
<a name="eventsObjectRead"></a>receive | [[Message Object](#messageObject)] | A list of messages a consumer can receive from the API.
<a name="eventsObjectWrite"></a>send | [[Message Object](#messageObject)] | A list of messages a consumer can send to the API.

Either `receive` or `send` MUST be provided.

This object can be extended with [Specification Extensions](#specificationExtensions).

##### Events Object Example

```json
{
"events": {
"receive": [
{ "$ref": "#/components/messages/chatMessage" },
{ "$ref": "#/components/messages/heartbeat" }
]
}
}
```

```yaml
events:
receive:
- $ref: '#/components/messages/chatMessage'
- $ref: '#/components/messages/heartbeat'
```







#### <a name="messageObject"></a>Message Object

Describes a message received on a given topic and operation.
Expand Down
52 changes: 52 additions & 0 deletions schema/asyncapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
"required": [
"stream"
]
},
{
"required": [
"events"
]
}
],
"additionalProperties": false,
Expand Down Expand Up @@ -58,6 +63,10 @@
"$ref": "#/definitions/stream",
"description": "The list of messages a consumer can read or write from/to a streaming API."
},
"events": {
"$ref": "#/definitions/events",
"description": "The list of messages an events API sends and/or receives."
},
"components": {
"$ref": "#/definitions/components"
},
Expand Down Expand Up @@ -659,6 +668,49 @@
}
}
},
"events": {
"title": "Events Object",
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^x-": {
"$ref": "#/definitions/vendorExtension"
}
},
"minProperties": 1,
"anyOf": [
{
"required": [
"receive"
]
},
{
"required": [
"send"
]
}
],
"properties": {
"receive": {
"title": "Events Receive Object",
"type": "array",
"uniqueItems": true,
"minItems": 1,
"items": {
"$ref": "#/definitions/message"
}
},
"send": {
"title": "Events Send Object",
"type": "array",
"uniqueItems": true,
"minItems": 1,
"items": {
"$ref": "#/definitions/message"
}
}
}
},
"message": {
"type": "object",
"additionalProperties": false,
Expand Down
Loading