Skip to content

Commit

Permalink
feat: add mqtt bindings schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
derberg committed Dec 4, 2023
1 parent f37fe59 commit 204554d
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 102 deletions.
53 changes: 50 additions & 3 deletions bindings/mqtt/0.2.0/message.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,54 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://asyncapi.com/bindings/mqtt/0.2.0/message.json",
"$id": "http://asyncapi.com/bindings/mqtt/0.0.2/message.json",
"title": "MQTT message bindings object",
"description": "This object contains information about the message representation in MQTT.",
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^x-[\\w\\d\\.\\x2d_]+$": {
"^x-[\\w\\d\\.\\-\\_]+$": {
"$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json"
}
},
"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": "https://asyncapi.com/definitions/3.0.0/schema.json"
},
{
"$ref": "https://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": "https://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"
}
]
}
}
24 changes: 21 additions & 3 deletions bindings/mqtt/0.2.0/operation.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://asyncapi.com/bindings/mqtt/0.2.0/operation.json",
"$id": "http://asyncapi.com/bindings/mqtt/0.0.2/operation.json",
"title": "MQTT operation bindings object",
"description": "This object contains information about the operation representation in MQTT.",
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^x-[\\w\\d\\.\\x2d_]+$": {
"^x-[\\w\\d\\.\\-\\_]+$": {
"$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json"
}
},
"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": "https://asyncapi.com/definitions/3.0.0/schema.json"
},
{
"$ref": "https://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"
}
]
}
}
44 changes: 39 additions & 5 deletions bindings/mqtt/0.2.0/server.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://asyncapi.com/bindings/mqtt/0.2.0/server.json",
"title": "MQTT server bindings object",
"$id": "http://asyncapi.com/bindings/mqtt/0.0.2/server.json",
"title": "Server Schema",
"description": "This object contains information about the server representation in MQTT.",
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^x-[\\w\\d\\.\\x2d_]+$": {
"^x-[\\w\\d\\.\\-\\_]+$": {
"$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json"
}
},
"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": "https://asyncapi.com/definitions/3.0.0/schema.json"
},
{
"$ref": "https://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": "https://asyncapi.com/definitions/3.0.0/schema.json"
},
{
"$ref": "https://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 204554d

Please sign in to comment.