Skip to content

Commit

Permalink
feat: add mqtt bindings schemas (#464)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergio Moya <[email protected]>
  • Loading branch information
derberg and smoya committed Dec 4, 2023
1 parent a7504d2 commit d29dbfa
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 96 deletions.
49 changes: 48 additions & 1 deletion bindings/mqtt/0.2.0/message.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,44 @@
}
},
"properties": {
"payloadFormatIndicator": {
"type": "integer",
"enum": [0, 1],
"description": "1 indicates that the payload is UTF-8 encoded character data. 0 indicates that the payload format is unspecified.",
"default": 0
},
"correlationData": {
"oneOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
}
],
"description": "Correlation Data is used by the sender of the request message to identify which request the response message is for when it is received."
},
"contentType": {
"type": "string",
"description": "String describing the content type of the message payload. This should not conflict with the contentType field of the associated AsyncAPI Message object."
},
"responseTopic": {
"oneOf": [
{
"type": "string",
"format": "uri-template",
"minLength": 1
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
}
],
"description": "The topic (channel URI) to be used for a response message."
},

"bindingVersion": {
"type": "string",
"enum": [
Expand All @@ -22,6 +60,15 @@
"examples": [
{
"bindingVersion": "0.2.0"
},
{
"contentType": "application/json",
"correlationData": {
"type": "string",
"format": "uuid"
},
"responseTopic": "application/responses",
"bindingVersion": "0.2.0"
}
]
}
}
20 changes: 19 additions & 1 deletion bindings/mqtt/0.2.0/operation.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,29 @@
"properties": {
"qos": {
"type": "integer",
"enum": [0,1,2],
"description": "Defines the Quality of Service (QoS) levels for the message flow between client and server. Its value MUST be either 0 (At most once delivery), 1 (At least once delivery), or 2 (Exactly once delivery)."
},
"retain": {
"type": "boolean",
"description": "Whether the broker should retain the message or not."
},
"messageExpiryInterval": {
"oneOf": [
{
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
}
],
"description": "Lifetime of the message in seconds"
},
"bindingVersion": {
"type": "string",
"enum": [
Expand All @@ -31,7 +48,8 @@
{
"qos": 2,
"retain": true,
"messageExpiryInterval": 60,
"bindingVersion": "0.2.0"
}
]
}
}
40 changes: 37 additions & 3 deletions bindings/mqtt/0.2.0/server.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://asyncapi.com/bindings/mqtt/0.2.0/server.json",
"title": "MQTT server bindings object",
"title": "Server Schema",
"description": "This object contains information about the server representation in MQTT.",
"type": "object",
"additionalProperties": false,
Expand All @@ -11,13 +11,14 @@
}
},
"properties": {

"clientId": {
"type": "string",
"description": "The client identifier."
},
"cleanSession": {
"type": "boolean",
"description": "Whether to create a persistent connection or not. When 'false', the connection will be persistent."
"description": "Whether to create a persistent connection or not. When 'false', the connection will be persistent. This is called clean start in MQTTv5."
},
"lastWill": {
"type": "object",
Expand Down Expand Up @@ -46,6 +47,37 @@
"type": "integer",
"description": "Interval in seconds of the longest period of time the broker and the client can endure without sending a message."
},
"sessionExpiryInterval": {
"oneOf": [
{
"type": "integer",
"minimum": 0
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
}
],
"description": "Interval time in seconds or a Schema Object containing the definition of the interval. The broker maintains a session for a disconnected client until this interval expires."
},
"maximumPacketSize": {
"oneOf": [
{
"type": "integer",
"minimum": 1,
"maximum": 4294967295
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
}
],
"description": "Number of bytes or a Schema Object representing the Maximum Packet Size the Client is willing to accept."
},
"bindingVersion": {
"type": "string",
"enum": [
Expand All @@ -65,7 +97,9 @@
"retain": false
},
"keepAlive": 60,
"sessionExpiryInterval": 120,
"maximumPacketSize": 1024,
"bindingVersion": "0.2.0"
}
]
}
}
53 changes: 0 additions & 53 deletions bindings/mqtt5/0.2.0/server.json

This file was deleted.

1 change: 0 additions & 1 deletion definitions/3.0.0/channelBindingsObject.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
},
"amqp1": {},
"mqtt": {},
"mqtt5": {},
"kafka": {
"properties": {
"bindingVersion": {
Expand Down
1 change: 0 additions & 1 deletion definitions/3.0.0/messageBindingsObject.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
}
]
},
"mqtt5": { },
"kafka": {
"properties": {
"bindingVersion": {
Expand Down
1 change: 0 additions & 1 deletion definitions/3.0.0/operationBindingsObject.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
}
]
},
"mqtt5": {},
"kafka": {
"properties": {
"bindingVersion": {
Expand Down
35 changes: 0 additions & 35 deletions definitions/3.0.0/serverBindingsObject.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,41 +47,6 @@
}
]
},
"mqtt5": {
"properties": {
"bindingVersion": {
"enum": ["0.2.0"]
}
},
"allOf": [
{
"description": "If no bindingVersion specified, use the latest binding",
"if": {
"not": {
"required": [
"bindingVersion"
]
}
},
"then": {
"$ref": "http://asyncapi.com/bindings/mqtt5/0.2.0/server.json"
}
},
{
"if": {
"required": [ "bindingVersion" ],
"properties": {
"bindingVersion": {
"const": "0.2.0"
}
}
},
"then": {
"$ref": "http://asyncapi.com/bindings/mqtt5/0.2.0/server.json"
}
}
]
},
"kafka": {
"properties": {
"bindingVersion": {
Expand Down

0 comments on commit d29dbfa

Please sign in to comment.