diff --git a/examples/next/rpc-client.yml b/examples/next/rpc-client.yml new file mode 100644 index 00000000..c610931b --- /dev/null +++ b/examples/next/rpc-client.yml @@ -0,0 +1,70 @@ +asyncapi: '2.0.0' +id: 'urn:rpc:example:client' +defaultContentType: application/json + +info: + title: RPC Client Example + description: This example demonstrates how to define an RPC client. + version: '1.0.0' + +servers: + - url: rabbitmq.example.org + scheme: amqp + +channels: + '{queue}': + parameters: + - name: queue + schema: + type: string + pattern: '^amq\\.gen\\-.+$' + protocolInfo: + amqp-0-9-1: + channelIsQueue: true + queue: + randomName: true + exclusive: true + subscribe: + operationId: receiveSumResult + protocolInfo: + amqp-0-9-1: + noAck: true + message: + correlationId: + location: $message.header#/correlation_id + payload: + type: object + properties: + result: + type: number + examples: + - 7 + + rpc_queue: + protocolInfo: + amqp-0-9-1: + channelIsQueue: true + queue: + durable: false + publish: + operationId: requestSum + protocolInfo: + amqp-0-9-1: + ack: true + message: + protocolInfo: + amqp-0-9-1: + properties: + reply_to: + type: string + correlationId: + location: $message.header#/correlation_id + payload: + type: object + properties: + numbers: + type: array + items: + type: number + examples: + - [4,3] diff --git a/examples/next/rpc-server.yml b/examples/next/rpc-server.yml new file mode 100644 index 00000000..3f35d2c2 --- /dev/null +++ b/examples/next/rpc-server.yml @@ -0,0 +1,67 @@ +asyncapi: '2.0.0' +id: 'urn:rpc:example:server' +defaultContentType: application/json + +info: + title: RPC Server Example + description: This example demonstrates how to define an RPC server. + version: '1.0.0' + +servers: + - url: rabbitmq.example.org + scheme: amqp + +channels: + '{queue}': + parameters: + - name: queue + schema: + type: string + pattern: '^amq\\.gen\\-.+$' + protocolInfo: + amqp-0-9-1: + channelIsQueue: true + queue: + randomName: true + exclusive: true + publish: + operationId: sendSumResult + protocolInfo: + amqp-0-9-1: + ack: true + message: + correlationId: + location: $message.header#/correlation_id + payload: + type: object + properties: + result: + type: number + examples: + - 7 + + rpc_queue: + protocolInfo: + amqp-0-9-1: + channelIsQueue: true + queue: + durable: false + subscribe: + operationId: sum + message: + protocolInfo: + amqp-0-9-1: + properties: + reply_to: + type: string + correlationId: + location: $message.header#/correlation_id + payload: + type: object + properties: + numbers: + type: array + items: + type: number + examples: + - [4,3] diff --git a/versions/next/asyncapi.md b/versions/next/asyncapi.md index 4c010526..24e90454 100644 --- a/versions/next/asyncapi.md +++ b/versions/next/asyncapi.md @@ -61,6 +61,7 @@ Means that the [application](#definitionsApplication) is a [consumer](#definitio - [XML Object](#xmlObject) - [Security Scheme Object](#securitySchemeObject) - [Parameter Object](#parameterObject) + - [Protocol Info Object](#protocolInfoObject) - [Correlation ID Object](#correlationIdObject) - [Specification Extensions](#specificationExtensions) @@ -516,6 +517,7 @@ Field Name | Type | Description subscribe | [Operation Object](#operationObject) | A definition of the SUBSCRIBE operation. publish | [Operation Object](#operationObject) | A definition of the PUBLISH operation. parameters | [[Parameter Object](#parameterObject) | [Reference Object](#referenceObject)] | A list of the parameters included in the channel name. It SHOULD be present only when using channels with expressions (as defined by [RFC 6570 section 2.2](https://tools.ietf.org/html/rfc6570#section-2.2)). +protocolInfo | Map[`string`, [Protocol Info Object](#protocolInfoObject)] | A free-form map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the channel. This object can be extended with [Specification Extensions](#specificationExtensions). @@ -539,6 +541,12 @@ This object can be extended with [Specification Extensions](#specificationExtens } } } + }, + "amqp-0-9-1": { + "channelIsQueue": true, + "queue": { + "exclusive": true + } } } ``` @@ -554,7 +562,10 @@ subscribe: user: $ref: "#/components/schemas/user" signup: - $ref: "#/components/schemas/signup" +amqp-0-9-1: + channelIsQueue: true + queue: + exclusive: true ``` Using `oneOf` to specify multiple messages per operation: @@ -599,6 +610,7 @@ Field Name | Type | Description description | `string` | A verbose explanation of the operation. [CommonMark syntax](http://spec.commonmark.org/) can be used for rich text representation. tags | [[Tag Object](#tagObject)] | A list of tags for API documentation control. Tags can be used for logical grouping of operations. externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this operation. +protocolInfo | Map[`string`, [Protocol Info Object](#protocolInfoObject)] | A free-form map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the operation. message | [Message Object](#messageObject) | A definition of the message that will be published or received on this channel. `oneOf` is allowed here to specify multiple messages, however, **a message MUST be valid only against one of the referenced message objects.** This object can be extended with [Specification Extensions](#specificationExtensions). @@ -633,6 +645,9 @@ This object can be extended with [Specification Extensions](#specificationExtens } } } + }, + "amqp-0-9-1": { + "noAck": true } } ``` @@ -657,6 +672,8 @@ message: $ref: "#/components/schemas/userCreate" signup: $ref: "#/components/schemas/signup" +amqp-0-9-1: + noAck: true ``` @@ -713,6 +730,42 @@ user.{userId}.signup: +#### Protocol Info Object + +Free-form key-value object describing protocol-specific definitions for channels, operations, and messages. + +##### Patterned Fields + +Field Pattern | Type | Description +---|:---:|--- +{protocol} | `Map` | Protocol-specific information. This map is free-form and MUST not be validated by parsers. + +##### Protocol Info Object Example + +```json +{ + "amqp-0-9-1": { + "channelIsQueue": true, + "queue": { + "randomName": true, + "exclusive": true + } + } +} +``` + +```yaml +amqp-0-9-1: + channelIsQueue: true + queue: + randomName: true + exclusive: true +``` + + + + + #### Stream Object Holds the framing configuration and the read/write operations for the streaming API. @@ -817,6 +870,7 @@ Field Name | Type | Description description | `string` | A verbose explanation of the message. [CommonMark syntax](http://spec.commonmark.org/) can be used for rich text representation. tags | [[Tag Object](#tagObject)] | A list of tags for API documentation control. Tags can be used for logical grouping of messages. externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this message. +protocolInfo | Map[`string`, [Protocol Info Object](#protocolInfoObject)] | A free-form map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the message. examples | [Map[`string`, `any`]] | An array with examples of valid message objects. This object can be extended with [Specification Extensions](#specificationExtensions). @@ -859,6 +913,11 @@ This object can be extended with [Specification Extensions](#specificationExtens "correlationId": { "description": "Default Correlation ID", "location": "$message.header#/correlationId" + }, + "amqp-0-9-1": { + "properties": { + "delivery_mode": 2 + } } } ``` @@ -890,6 +949,9 @@ payload: correlationId: description: Default Correlation ID location: $message.header#/correlationId +amqp-0-9-1: + properties: + delivery_mode: 2 ``` Example using Google's protobuf to define the payload: diff --git a/versions/next/schema.json b/versions/next/schema.json index c6a84e5b..f690f0e7 100644 --- a/versions/next/schema.json +++ b/versions/next/schema.json @@ -557,6 +557,12 @@ "deprecated": { "type": "boolean", "default": false + }, + "protocolInfo": { + "type": "object", + "additionalProperties": { + "type": "object" + } } } }, @@ -617,6 +623,12 @@ "operationId": { "type": "string" }, + "protocolInfo": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, "message": { "oneOf": [ { @@ -728,86 +740,79 @@ } }, "message": { - "anyOf": [ - { + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^x-": { + "$ref": "#/definitions/vendorExtension" + } + }, + "properties": { + "schemaFormat": { + "type": "string" + }, + "contentType": { + "type": "string" + }, + "headers": { "type": "object", - "additionalProperties": false, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } + "additionalProperties": { + "oneOf": [ + { "$ref": "#/definitions/Reference" }, + {"$ref": "#/definitions/schema" } + ] } }, - { - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^x-": { - "$ref": "#/definitions/vendorExtension" - } + "payload": {}, + "correlationId": { + "oneOf": [ + { "$ref": "#/definitions/Reference" }, + { "$ref": "#/definitions/correlationId" } + ] + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/definitions/tag" }, - "properties": { - "schemaFormat": { - "type": "string" - }, - "contentType": { - "type": "string" - }, - "headers": { - "type": "object", - "additionalProperties": { - "oneOf": [ - { "$ref": "#/definitions/Reference" }, - {"$ref": "#/definitions/schema" } - ] - } - }, - "payload": {}, - "correlationId": { - "oneOf": [ - { "$ref": "#/definitions/Reference" }, - { "$ref": "#/definitions/correlationId" } - ] - }, - "tags": { - "type": "array", - "items": { - "$ref": "#/definitions/tag" - }, - "uniqueItems": true - }, - "summary": { - "type": "string", - "description": "A brief summary of the message." - }, - "name": { - "type": "string", - "description": "Name of the message." - }, - "title": { - "type": "string", - "description": "A human-friendly title for the message." - }, - "description": { - "type": "string", - "description": "A longer description of the message. CommonMark is allowed." - }, - "externalDocs": { - "$ref": "#/definitions/externalDocs" - }, - "deprecated": { - "type": "boolean", - "default": false - }, - "examples": { - "type": "array", - "items": { - "type": "object" - } - } + "uniqueItems": true + }, + "summary": { + "type": "string", + "description": "A brief summary of the message." + }, + "name": { + "type": "string", + "description": "Name of the message." + }, + "title": { + "type": "string", + "description": "A human-friendly title for the message." + }, + "description": { + "type": "string", + "description": "A longer description of the message. CommonMark is allowed." + }, + "externalDocs": { + "$ref": "#/definitions/externalDocs" + }, + "deprecated": { + "type": "boolean", + "default": false + }, + "examples": { + "type": "array", + "items": { + "type": "object" + } + }, + "protocolInfo": { + "type": "object", + "additionalProperties": { + "type": "object" } } - ] + } }, "correlationId": { "type": "object",