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

feat: allow servers and channels to be defined as components #665

Merged
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
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 @@ -1433,6 +1433,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 @@ -1489,6 +1491,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 @@ -1574,6 +1593,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