Skip to content

Commit

Permalink
Merge pull request #74 from asyncapi/feature/event-apis
Browse files Browse the repository at this point in the history
Add support for Events APIs
  • Loading branch information
fmvilas authored Apr 13, 2018
2 parents c624fad + d2b98c7 commit b9c7f00
Show file tree
Hide file tree
Showing 3 changed files with 975 additions and 2 deletions.
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

0 comments on commit b9c7f00

Please sign in to comment.