Skip to content

Commit

Permalink
feat: allow servers and channels to be defined as components
Browse files Browse the repository at this point in the history
  • Loading branch information
smoya authored Jan 13, 2022
1 parent bd63cfb commit d4c87b9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
3 changes: 1 addition & 2 deletions examples/social-media/backend/asyncapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ info:

servers:
websiteWebSocketServer:
url: ws://mycompany.com/ws
protocol: ws
$ref: '../common/servers.yaml#/websiteWebSocketServer'
mosquitto:
url: mqtt://test.mosquitto.org
protocol: mqtt
Expand Down
3 changes: 3 additions & 0 deletions examples/social-media/common/servers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
websiteWebSocketServer:
url: ws://mycompany.com/ws
protocol: ws
3 changes: 1 addition & 2 deletions examples/social-media/frontend/asyncapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ info:

servers:
websiteWebSocketServer:
url: ws://mycompany.com/ws
protocol: ws
$ref: '../common/servers.yaml#/websiteWebSocketServer'

channels:
like/comment:
Expand Down
30 changes: 30 additions & 0 deletions spec/asyncapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,8 @@ All objects defined within the components object will have no effect on the API
Field Name | Type | Description
---|:---|---
<a name="componentsSchemas"></a> schemas | Map[`string`, [Schema Object](#schemaObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Schema Objects](#schemaObject).
<a name="componentsServers"></a> servers | Map[`string`, [Server Object](#serverObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Server Objects](#serverObject).
<a name="componentsChannels"></a> channels | Map[`string`, [Channel Object](#channelItemObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Channel Objects](#channelItemObject).
<a name="componentsMessages"></a> messages | Map[`string`, [Message Object](#messageObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Message Objects](#messageObject).
<a name="componentsSecuritySchemes"></a> securitySchemes| Map[`string`, [Security Scheme Object](#securitySchemeObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Security Scheme Objects](#securitySchemeObject).
<a name="componentsParameters"></a> parameters | Map[`string`, [Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Parameter Objects](#parameterObject).
Expand Down Expand Up @@ -1493,6 +1495,23 @@ my.org.User
}
}
},
"servers": {
"development": {
"url": "development.gigantic-server.com",
"description": "Development server",
"protocol": "amqp",
"protocolVersion": "0.9.1"
}
},
"channels": {
"user/signedup": {
"subscribe": {
"message": {
"$ref": "#/components/messages/userSignUp"
}
}
}
},
"messages": {
"userSignUp": {
"summary": "Action to sign a user up.",
Expand Down Expand Up @@ -1578,6 +1597,17 @@ components:
format: int64
name:
type: string
servers:
development:
url: development.gigantic-server.com
description: Development server
protocol: amqp
protocolVersion: 0.9.1
channels:
user/signedup:
subscribe:
message:
$ref: "#/components/messages/userSignUp"
messages:
userSignUp:
summary: Action to sign a user up.
Expand Down

0 comments on commit d4c87b9

Please sign in to comment.