diff --git a/bindings/amqp/0.4.0/channel.json b/bindings/amqp/0.4.0/channel.json new file mode 100644 index 00000000..d2a7a854 --- /dev/null +++ b/bindings/amqp/0.4.0/channel.json @@ -0,0 +1,149 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://asyncapi.com/bindings/amqp/0.4.0/channel.json", + "title": "AMQP channel bindings object", + "description": "This object contains information about the channel representation in AMQP.", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" + } + }, + "properties": { + "is": { + "type": "string", + "enum": ["queue", "routingKey"], + "description": "Defines what type of channel is it. Can be either 'queue' or 'routingKey' (default)." + }, + "name": { + "type": "string", + "maxLength": 255, + "description": "When is=routingKey, this defines the actual routing pattern to route the message from the exchange to the queue." + }, + "channel": { + "type": "object", + "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" + }, + "exchange": { + "type": "object", + "properties": { + "name": { + "type": "string", + "maxLength": 255, + "description": "The name of the exchange. It MUST NOT exceed 255 characters long." + }, + "type": { + "type": "string", + "enum": ["topic", "direct", "fanout", "default", "headers"], + "description": "The type of the exchange. Can be either 'topic', 'direct', 'fanout', 'default' or 'headers'." + }, + "durable": { + "type": "boolean", + "description": "Whether the exchange should survive broker restarts or not." + }, + "autoDelete": { + "type": "boolean", + "description": "Whether the exchange should be deleted when the last queue is unbound from it." + }, + "vhost": { + "type": "string", + "default": "/", + "description": "The virtual host of the exchange. Defaults to '/'." + } + }, + "description": "When is=routingKey, this object defines the exchange properties." + }, + "queue": { + "type": "object", + "properties": { + "name": { + "type": "string", + "maxLength": 255, + "description": "The name of the queue. It MUST NOT exceed 255 characters long." + }, + "durable": { + "type": "boolean", + "description": "Whether the queue should survive broker restarts or not." + }, + "exclusive": { + "type": "boolean", + "description": "Whether the queue should be used only by one connection or not." + }, + "autoDelete": { + "type": "boolean", + "description": "Whether the queue should be deleted when the last consumer unsubscribes." + }, + "vhost": { + "type": "string", + "default": "/", + "description": "The virtual host of the queue. Defaults to '/'." + } + }, + "description": "When is=queue, this object defines the queue properties." + }, + "bindingVersion": { + "type": "string", + "enum": [ + "0.4.0" + ], + "description": "The version of this binding. If omitted, 'latest' MUST be assumed." + } + }, + "oneOf": [ + { + "properties": { + "is": { "const": "routingKey" } + }, + "required": [ + "exchange" + ], + "not": { + "required": [ + "queue" + ] + } + }, + { + "properties": { + "is": { "const": "queue" } + }, + "required": [ + "queue" + ], + "not": { + "required": [ + "exchange" + ] + } + } + ], + "examples": [ + { + "is": "routingKey", + "name": "routing.pattern", + "channel": { + "$ref": "#/components/channels/my-queue-name" + }, + "exchange": { + "name": "myExchange", + "type": "topic", + "durable": true, + "autoDelete": false, + "vhost": "/" + }, + "bindingVersion": "0.4.0" + }, + { + "is": "queue", + "queue": { + "name": "my-queue-name", + "durable": true, + "exclusive": true, + "autoDelete": false, + "vhost": "/" + }, + "bindingVersion": "0.4.0" + } + ] +} diff --git a/bindings/amqp/0.4.0/message.json b/bindings/amqp/0.4.0/message.json new file mode 100644 index 00000000..2d696f6c --- /dev/null +++ b/bindings/amqp/0.4.0/message.json @@ -0,0 +1,37 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://asyncapi.com/bindings/amqp/0.4.0/message.json", + "title": "AMQP message bindings object", + "description": "This object contains information about the message representation in AMQP.", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" + } + }, + "properties": { + "contentEncoding": { + "type": "string", + "description": "A MIME encoding for the message content." + }, + "messageType": { + "type": "string", + "description": "Application-specific message type." + }, + "bindingVersion": { + "type": "string", + "enum": [ + "0.4.0" + ], + "description": "The version of this binding. If omitted, \"latest\" MUST be assumed." + } + }, + "examples": [ + { + "contentEncoding": "gzip", + "messageType": "user.signup", + "bindingVersion": "0.4.0" + } + ] +} diff --git a/bindings/amqp/0.4.0/operation.json b/bindings/amqp/0.4.0/operation.json new file mode 100644 index 00000000..cd7fc0e5 --- /dev/null +++ b/bindings/amqp/0.4.0/operation.json @@ -0,0 +1,84 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://asyncapi.com/bindings/amqp/0.4.0/operation.json", + "title": "AMQP operation bindings object", + "description": "This object contains information about the operation representation in AMQP.", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" + } + }, + "properties": { + "expiration": { + "type": "integer", + "minimum": 0, + "description": "TTL (Time-To-Live) for the message. It MUST be greater than or equal to zero." + }, + "userId": { + "type": "string", + "description": "Identifies the user who has sent the message." + }, + "cc": { + "type": "array", + "items": { + "type": "string" + }, + "description": "The routing keys the message should be routed to at the time of publishing." + }, + "priority": { + "type": "integer", + "description": "A priority for the message." + }, + "deliveryMode": { + "type": "integer", + "enum": [1,2], + "description": "Delivery mode of the message. Its value MUST be either 1 (transient) or 2 (persistent)." + }, + "mandatory": { + "type": "boolean", + "description": "Whether the message is mandatory or not." + }, + "bcc": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Like cc but consumers will not receive this information." + }, + "timestamp": { + "type": "boolean", + "description": "Whether the message should include a timestamp or not." + }, + "ack": { + "type": "boolean", + "description": "Whether the consumer should ack the message or not." + }, + "bindingVersion": { + "type": "string", + "enum": [ + "0.4.0" + ], + "description": "The version of this binding. If omitted, \"latest\" MUST be assumed." + } + }, + "examples": [ + { + "expiration": 100000, + "userId": "guest", + "cc": [ + "user.logs" + ], + "priority": 10, + "deliveryMode": 2, + "mandatory": false, + "bcc": [ + "external.audit" + ], + "timestamp": true, + "ack": false, + "bindingVersion": "0.4.0" + } + ] +} diff --git a/test/ajv-schemes.js b/test/ajv-schemes.js index 8b2d79ad..557390ec 100644 --- a/test/ajv-schemes.js +++ b/test/ajv-schemes.js @@ -7,6 +7,9 @@ function bindingSchemes(ajv) { ajv.addSchema(require('@bindings/amqp/0.3.0/channel.json')); ajv.addSchema(require('@bindings/amqp/0.3.0/message.json')); ajv.addSchema(require('@bindings/amqp/0.3.0/operation.json')); + ajv.addSchema(require('@bindings/amqp/0.4.0/channel.json')); + ajv.addSchema(require('@bindings/amqp/0.4.0/message.json')); + ajv.addSchema(require('@bindings/amqp/0.4.0/operation.json')); ajv.addSchema(require('@bindings/anypointmq/0.0.1/channel.json')); ajv.addSchema(require('@bindings/anypointmq/0.0.1/message.json')); diff --git a/test/bindings/amqp/amqp channel binding.test.mjs b/test/bindings/amqp/amqp channel binding.test.mjs index 74173ef9..de8795ea 100644 --- a/test/bindings/amqp/amqp channel binding.test.mjs +++ b/test/bindings/amqp/amqp channel binding.test.mjs @@ -160,12 +160,100 @@ let data = { }, "ext-number": 1 } + ), + "0.4.0": new JsonSchemaTestSuiteData( + require(`@bindings/amqp/0.4.0/channel.json`), + [ + { + "is": "queue", + "queue": { + "name": "my-queue-name", + "durable": true, + "exclusive": true, + "autoDelete": false, + "vhost": "/" + }, + "bindingVersion": "0.4.0" + }, + { + "is": "routingKey", + "exchange": { + "name": "myExchange", + "type": "topic", + "durable": true, + "autoDelete": false, + "vhost": "/" + }, + "bindingVersion": "0.4.0" + }, + { + "is": "routingKey", + "name": "routingKeyName", + "channel": { + "$ref": "#/components/channels/queue-update" + }, + "exchange": { + "name": "myExchange", + "type": "topic", + "durable": true, + "autoDelete": false, + "vhost": "/" + }, + "bindingVersion": "0.4.0" + } + ], + { + "is": "queue", + "queue": { + "name": "my-queue-name", + "durable": true, + "exclusive": true, + "autoDelete": false, + "vhost": "/" + }, + "bindingVersion": "0.4.0" + }, + { + "bindingVersion": "0.4.0" + }, + { + "is": "queue", + "queue": { + "name": "my-queue-name", + "durable": true, + "exclusive": true, + "autoDelete": false, + "vhost": "/" + }, + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "is": "queue", + "queue": { + "name": "my-queue-name", + "durable": true, + "exclusive": true, + "autoDelete": false, + "vhost": "/" + }, + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } ) } describe.each([ '0.2.0', - '0.3.0' + '0.3.0', + '0.4.0', ])('AMQP channel binding v%s', (bindingVersion) => { new JsonSchemaTestSuite(data[bindingVersion], config).testSuite() }) diff --git a/test/bindings/amqp/amqp message binding.test.mjs b/test/bindings/amqp/amqp message binding.test.mjs index ffbcc3a5..3f8d11cc 100644 --- a/test/bindings/amqp/amqp message binding.test.mjs +++ b/test/bindings/amqp/amqp message binding.test.mjs @@ -66,12 +66,40 @@ let data = { }, "ext-number": 1 } + ), + "0.4.0": new JsonSchemaTestSuiteData( + require(`@bindings/amqp/0.4.0/message.json`), + [ + { + "contentEncoding": "gzip", + "messageType": "user.signup", + "bindingVersion": "0.4.0" + } + ], + {}, + {}, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } ) } describe.each([ '0.2.0', - '0.3.0' + '0.3.0', + '0.4.0' ])('AMQP message binding v%s', (bindingVersion) => { new JsonSchemaTestSuite(data[bindingVersion], config).testSuite() }) diff --git a/test/bindings/amqp/amqp operation binding.test.mjs b/test/bindings/amqp/amqp operation binding.test.mjs index b5882714..368890bb 100644 --- a/test/bindings/amqp/amqp operation binding.test.mjs +++ b/test/bindings/amqp/amqp operation binding.test.mjs @@ -88,12 +88,51 @@ let data = { }, "ext-number": 1 } + ), + "0.4.0": new JsonSchemaTestSuiteData( + require(`@bindings/amqp/0.4.0/operation.json`), + [ + { + "expiration": 100000, + "userId": "guest", + "cc": [ + "user.logs" + ], + "priority": 10, + "deliveryMode": 2, + "mandatory": false, + "bcc": [ + "external.audit" + ], + "timestamp": true, + "ack": false, + "bindingVersion": "0.4.0" + } + ], + {}, + {}, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } ) } describe.each([ '0.2.0', - '0.3.0' + '0.3.0', + '0.4.0' ])('AMQP operation binding v%s', (bindingVersion) => { new JsonSchemaTestSuite(data[bindingVersion], config).testSuite() })