Skip to content

Commit a9b2e2b

Browse files
authored
Merge pull request asyncapi#170 from asyncapi/feature/protocol-objects
Add support for Protocol Info objects
2 parents 2f92eaa + 645dd72 commit a9b2e2b

File tree

4 files changed

+279
-75
lines changed

4 files changed

+279
-75
lines changed

examples/next/rpc-client.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
asyncapi: '2.0.0'
2+
id: 'urn:rpc:example:client'
3+
defaultContentType: application/json
4+
5+
info:
6+
title: RPC Client Example
7+
description: This example demonstrates how to define an RPC client.
8+
version: '1.0.0'
9+
10+
servers:
11+
- url: rabbitmq.example.org
12+
scheme: amqp
13+
14+
channels:
15+
'{queue}':
16+
parameters:
17+
- name: queue
18+
schema:
19+
type: string
20+
pattern: '^amq\\.gen\\-.+$'
21+
protocolInfo:
22+
amqp-0-9-1:
23+
channelIsQueue: true
24+
queue:
25+
randomName: true
26+
exclusive: true
27+
subscribe:
28+
operationId: receiveSumResult
29+
protocolInfo:
30+
amqp-0-9-1:
31+
noAck: true
32+
message:
33+
correlationId:
34+
location: $message.header#/correlation_id
35+
payload:
36+
type: object
37+
properties:
38+
result:
39+
type: number
40+
examples:
41+
- 7
42+
43+
rpc_queue:
44+
protocolInfo:
45+
amqp-0-9-1:
46+
channelIsQueue: true
47+
queue:
48+
durable: false
49+
publish:
50+
operationId: requestSum
51+
protocolInfo:
52+
amqp-0-9-1:
53+
ack: true
54+
message:
55+
protocolInfo:
56+
amqp-0-9-1:
57+
properties:
58+
reply_to:
59+
type: string
60+
correlationId:
61+
location: $message.header#/correlation_id
62+
payload:
63+
type: object
64+
properties:
65+
numbers:
66+
type: array
67+
items:
68+
type: number
69+
examples:
70+
- [4,3]

examples/next/rpc-server.yml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
asyncapi: '2.0.0'
2+
id: 'urn:rpc:example:server'
3+
defaultContentType: application/json
4+
5+
info:
6+
title: RPC Server Example
7+
description: This example demonstrates how to define an RPC server.
8+
version: '1.0.0'
9+
10+
servers:
11+
- url: rabbitmq.example.org
12+
scheme: amqp
13+
14+
channels:
15+
'{queue}':
16+
parameters:
17+
- name: queue
18+
schema:
19+
type: string
20+
pattern: '^amq\\.gen\\-.+$'
21+
protocolInfo:
22+
amqp-0-9-1:
23+
channelIsQueue: true
24+
queue:
25+
randomName: true
26+
exclusive: true
27+
publish:
28+
operationId: sendSumResult
29+
protocolInfo:
30+
amqp-0-9-1:
31+
ack: true
32+
message:
33+
correlationId:
34+
location: $message.header#/correlation_id
35+
payload:
36+
type: object
37+
properties:
38+
result:
39+
type: number
40+
examples:
41+
- 7
42+
43+
rpc_queue:
44+
protocolInfo:
45+
amqp-0-9-1:
46+
channelIsQueue: true
47+
queue:
48+
durable: false
49+
subscribe:
50+
operationId: sum
51+
message:
52+
protocolInfo:
53+
amqp-0-9-1:
54+
properties:
55+
reply_to:
56+
type: string
57+
correlationId:
58+
location: $message.header#/correlation_id
59+
payload:
60+
type: object
61+
properties:
62+
numbers:
63+
type: array
64+
items:
65+
type: number
66+
examples:
67+
- [4,3]

versions/next/asyncapi.md

+63-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Means that the [application](#definitionsApplication) is a [consumer](#definitio
6161
- [XML Object](#xmlObject)
6262
- [Security Scheme Object](#securitySchemeObject)
6363
- [Parameter Object](#parameterObject)
64+
- [Protocol Info Object](#protocolInfoObject)
6465
- [Correlation ID Object](#correlationIdObject)
6566
- [Specification Extensions](#specificationExtensions)
6667

@@ -516,6 +517,7 @@ Field Name | Type | Description
516517
<a name="channelItemObjectSubscribe"></a>subscribe | [Operation Object](#operationObject) | A definition of the SUBSCRIBE operation.
517518
<a name="channelItemObjectPublish"></a>publish | [Operation Object](#operationObject) | A definition of the PUBLISH operation.
518519
<a name="channelItemObjectParameters"></a>parameters | [[Parameter Object](#parameterObject) &#124; [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)).
520+
<a name="channelItemObjectProtocolInfo"></a>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.
519521

520522
This object can be extended with [Specification Extensions](#specificationExtensions).
521523

@@ -539,6 +541,12 @@ This object can be extended with [Specification Extensions](#specificationExtens
539541
}
540542
}
541543
}
544+
},
545+
"amqp-0-9-1": {
546+
"channelIsQueue": true,
547+
"queue": {
548+
"exclusive": true
549+
}
542550
}
543551
}
544552
```
@@ -554,7 +562,10 @@ subscribe:
554562
user:
555563
$ref: "#/components/schemas/user"
556564
signup:
557-
$ref: "#/components/schemas/signup"
565+
amqp-0-9-1:
566+
channelIsQueue: true
567+
queue:
568+
exclusive: true
558569
```
559570

560571
Using `oneOf` to specify multiple messages per operation:
@@ -599,6 +610,7 @@ Field Name | Type | Description
599610
<a name="operationObjectDescription"></a>description | `string` | A verbose explanation of the operation. [CommonMark syntax](http://spec.commonmark.org/) can be used for rich text representation.
600611
<a name="operationObjectTags"></a>tags | [[Tag Object](#tagObject)] | A list of tags for API documentation control. Tags can be used for logical grouping of operations.
601612
<a name="operationObjectExternalDocs"></a>externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this operation.
613+
<a name="operationObjectProtocolInfo"></a>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.
602614
<a name="operationObjectMessage"></a>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.**
603615

604616
This object can be extended with [Specification Extensions](#specificationExtensions).
@@ -633,6 +645,9 @@ This object can be extended with [Specification Extensions](#specificationExtens
633645
}
634646
}
635647
}
648+
},
649+
"amqp-0-9-1": {
650+
"noAck": true
636651
}
637652
}
638653
```
@@ -657,6 +672,8 @@ message:
657672
$ref: "#/components/schemas/userCreate"
658673
signup:
659674
$ref: "#/components/schemas/signup"
675+
amqp-0-9-1:
676+
noAck: true
660677
```
661678

662679

@@ -713,6 +730,42 @@ user.{userId}.signup:
713730

714731

715732

733+
#### <a name="protocolInfoObject"></a>Protocol Info Object
734+
735+
Free-form key-value object describing protocol-specific definitions for channels, operations, and messages.
736+
737+
##### Patterned Fields
738+
739+
Field Pattern | Type | Description
740+
---|:---:|---
741+
<a name="protocolInfoObjectProtocolName"></a>{protocol} | `Map` | Protocol-specific information. This map is free-form and MUST not be validated by parsers.
742+
743+
##### Protocol Info Object Example
744+
745+
```json
746+
{
747+
"amqp-0-9-1": {
748+
"channelIsQueue": true,
749+
"queue": {
750+
"randomName": true,
751+
"exclusive": true
752+
}
753+
}
754+
}
755+
```
756+
757+
```yaml
758+
amqp-0-9-1:
759+
channelIsQueue: true
760+
queue:
761+
randomName: true
762+
exclusive: true
763+
```
764+
765+
766+
767+
768+
716769
#### <a name="streamObject"></a>Stream Object
717770

718771
Holds the framing configuration and the read/write operations for the streaming API.
@@ -817,6 +870,7 @@ Field Name | Type | Description
817870
<a name="messageObjectDescription"></a>description | `string` | A verbose explanation of the message. [CommonMark syntax](http://spec.commonmark.org/) can be used for rich text representation.
818871
<a name="messageObjectTags"></a>tags | [[Tag Object](#tagObject)] | A list of tags for API documentation control. Tags can be used for logical grouping of messages.
819872
<a name="messageObjectExternalDocs"></a>externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this message.
873+
<a name="messageObjectProtocolInfo"></a>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.
820874
<a name="messageObjectExamples"></a>examples | [Map[`string`, `any`]] | An array with examples of valid message objects.
821875

822876
This object can be extended with [Specification Extensions](#specificationExtensions).
@@ -859,6 +913,11 @@ This object can be extended with [Specification Extensions](#specificationExtens
859913
"correlationId": {
860914
"description": "Default Correlation ID",
861915
"location": "$message.header#/correlationId"
916+
},
917+
"amqp-0-9-1": {
918+
"properties": {
919+
"delivery_mode": 2
920+
}
862921
}
863922
}
864923
```
@@ -890,6 +949,9 @@ payload:
890949
correlationId:
891950
description: Default Correlation ID
892951
location: $message.header#/correlationId
952+
amqp-0-9-1:
953+
properties:
954+
delivery_mode: 2
893955
```
894956

895957
Example using Google's protobuf to define the payload:

0 commit comments

Comments
 (0)