Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use maps instead of arrays when possible #245

Merged
merged 2 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions examples/next/application-headers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ info:
url: https://www.apache.org/licenses/LICENSE-2.0

servers:
- url: api.streetlights.smartylighting.com:{port}
production:
url: api.streetlights.smartylighting.com:{port}
protocol: mqtt
description: Test broker
variables:
Expand All @@ -24,7 +25,8 @@ defaultContentType: application/json
channels:
smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured:
parameters:
- $ref: '#/components/parameters/streetlightId'
streetlightId:
$ref: '#/components/parameters/streetlightId'
subscribe:
summary: Receive information about environmental lighting conditions of a particular streetlight.
operationId: receiveLightMeasurement
Expand Down Expand Up @@ -76,7 +78,6 @@ components:

parameters:
streetlightId:
name: streetlightId
description: The ID of the streetlight.
schema:
type: string
10 changes: 6 additions & 4 deletions examples/next/correlation-id.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ info:
url: https://www.apache.org/licenses/LICENSE-2.0

servers:
- url: api.streetlights.smartylighting.com:{port}
production:
url: api.streetlights.smartylighting.com:{port}
protocol: mqtt
description: Test broker
variables:
Expand All @@ -31,7 +32,8 @@ defaultContentType: application/json
channels:
smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured:
parameters:
- $ref: '#/components/parameters/streetlightId'
streetlightId:
$ref: '#/components/parameters/streetlightId'
subscribe:
summary: Receive information about environmental lighting conditions of a particular streetlight.
operationId: receiveLightMeasurement
Expand All @@ -40,7 +42,8 @@ channels:

smartylighting/streetlights/1/0/action/{streetlightId}/dim:
parameters:
- $ref: '#/components/parameters/streetlightId'
streetlightId:
$ref: '#/components/parameters/streetlightId'
publish:
operationId: dimLight
message:
Expand Down Expand Up @@ -93,7 +96,6 @@ components:

parameters:
streetlightId:
name: streetlightId
description: The ID of the streetlight.
schema:
type: string
Expand Down
7 changes: 4 additions & 3 deletions examples/next/gitter-streaming.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ info:
version: '1.0.0'

servers:
- url: https://stream.gitter.im/v1
production:
url: https://stream.gitter.im/v1
protocol: https
protocolVersion: '1.1'
security:
Expand All @@ -14,13 +15,13 @@ servers:
channels:
/rooms/{roomId}/{resource}:
parameters:
- name: roomId
roomId:
description: Id of the Gitter room.
schema:
type: string
examples:
- 53307860c3599d1de448e19d
- name: resource
resource:
description: The resource to consume.
schema:
type: string
Expand Down
5 changes: 3 additions & 2 deletions examples/next/rpc-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ info:
version: '1.0.0'

servers:
- url: rabbitmq.example.org
production:
url: rabbitmq.example.org
protocol: amqp

channels:
'{queue}':
parameters:
- name: queue
queue:
schema:
type: string
pattern: '^amq\\.gen\\-.+$'
Expand Down
5 changes: 3 additions & 2 deletions examples/next/rpc-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ info:
version: '1.0.0'

servers:
- url: rabbitmq.example.org
production:
url: rabbitmq.example.org
protocol: amqp

channels:
'{queue}':
parameters:
- name: queue
queue:
schema:
type: string
pattern: '^amq\\.gen\\-.+$'
Expand Down
3 changes: 2 additions & 1 deletion examples/next/slack-rtm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ info:
version: '1.0.0'

servers:
- url: https://slack.com/api/rtm.connect
production:
url: https://slack.com/api/rtm.connect
protocol: https
protocolVersion: '1.1'
security:
Expand Down
16 changes: 10 additions & 6 deletions examples/next/streetlights.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ info:
url: https://www.apache.org/licenses/LICENSE-2.0

servers:
- url: api.streetlights.smartylighting.com:{port}
production:
url: api.streetlights.smartylighting.com:{port}
protocol: mqtt
description: Test broker
variables:
Expand All @@ -40,7 +41,8 @@ channels:
smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured:
description: The topic on which measured values may be produced and consumed.
parameters:
- $ref: '#/components/parameters/streetlightId'
streetlightId:
$ref: '#/components/parameters/streetlightId'
subscribe:
summary: Receive information about environmental lighting conditions of a particular streetlight.
operationId: receiveLightMeasurement
Expand All @@ -51,7 +53,8 @@ channels:

smartylighting/streetlights/1/0/action/{streetlightId}/turn/on:
parameters:
- $ref: '#/components/parameters/streetlightId'
streetlightId:
$ref: '#/components/parameters/streetlightId'
publish:
operationId: turnOn
traits:
Expand All @@ -61,7 +64,8 @@ channels:

smartylighting/streetlights/1/0/action/{streetlightId}/turn/off:
parameters:
- $ref: '#/components/parameters/streetlightId'
streetlightId:
$ref: '#/components/parameters/streetlightId'
publish:
operationId: turnOff
traits:
Expand All @@ -71,7 +75,8 @@ channels:

smartylighting/streetlights/1/0/action/{streetlightId}/dim:
parameters:
- $ref: '#/components/parameters/streetlightId'
streetlightId:
$ref: '#/components/parameters/streetlightId'
publish:
operationId: dimLight
traits:
Expand Down Expand Up @@ -184,7 +189,6 @@ components:

parameters:
streetlightId:
name: streetlightId
description: The ID of the streetlight.
schema:
type: string
Expand Down
92 changes: 81 additions & 11 deletions versions/next/asyncapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,35 @@ url: http://www.apache.org/licenses/LICENSE-2.0.html

#### <a name="serversObject"></a>Servers Object

The Servers Object is an array of Server Objects.
The Servers Object is a map of [Server Objects](#serverObject).

##### Patterned Fields

Field Pattern | Type | Description
---|:---:|---
<a name="serversObjectServer"></a>`^[A-Za-z0-9_\-]+$` | [Server Object](#serverObject) | The definition of a server this application MAY connect to.

##### Servers Object Example

```json
{
"production": {
"url": "development.gigantic-server.com",
"description": "Development server",
"protocol": "kafka",
"protocolVersion": "1.0.0"
}
}
```

```yaml
production:
url: development.gigantic-server.com
description: Development server
protocol: kafka
protocolVersion: '1.0.0'
```


#### <a name="serverObject"></a>Server Object

Expand Down Expand Up @@ -486,8 +514,6 @@ Field Pattern | Type | Description
---|:---:|---
<a name="channelsObjectChannel"></a>{channel} | [Channel Item Object](#channelItemObject) | A relative path to an individual channel. The field name MUST be in the form of a [RFC 6570 URI template](https://tools.ietf.org/html/rfc6570). Query parameters and fragments SHALL NOT be used, instead use [protocolInfo](#protocolInfoObject) to define them.

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

##### Channels Object Example

```json
Expand Down Expand Up @@ -521,7 +547,7 @@ Field Name | Type | Description
<a name="channelItemObjectDescription"></a>description | `string` | An optional description of this channel item. [CommonMark syntax](http://spec.commonmark.org/) can be used for rich text representation.
<a name="channelItemObjectSubscribe"></a>subscribe | [Operation Object](#operationObject) | A definition of the SUBSCRIBE operation.
<a name="channelItemObjectPublish"></a>publish | [Operation Object](#operationObject) | A definition of the PUBLISH operation.
<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)).
<a name="channelItemObjectParameters"></a>parameters | [Parameters Object](#parametersObject) | A map 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)).
<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.

This object can be extended with [Specification Extensions](#specificationExtensions).
Expand Down Expand Up @@ -737,6 +763,53 @@ protocolInfo:



#### <a name="parametersObject"></a>Parameters Object

Describes a map of parameters included in a channel name.

This map MUST contain all the parameters used in the parent channel name.

##### Patterned Fields

Field Pattern | Type | Description
---|:---:|---
<a name="parametersObjectName"></a>`^[A-Za-z0-9_\-]+$` | [Parameter Object](#parameterObject) &#124; [Reference Object](#referenceObject) | The key represents the name of the parameter. It MUST match the parameter name used in the parent channel name.

##### Parameters Object Example

```json
{
"user/{userId}/signup": {
"parameters": {
"userId": {
"description": "Id of the user.",
"schema": {
"type": "string"
}
}
},
"subscribe": {
"$ref": "#/components/messages/userSignedUp"
}
}
}
```

```yaml
user/{userId}/signup:
parameters:
userId:
description: Id of the user.
schema:
type: string
subscribe:
$ref: "#/components/messages/userSignedUp"
```





#### <a name="parameterObject"></a>Parameter Object

Describes a parameter included in a channel name.
Expand All @@ -745,7 +818,6 @@ Describes a parameter included in a channel name.

Field Name | Type | Description
---|:---:|---
<a name="parameterObjectName"></a>name | `string` | The name of the parameter.
<a name="parameterObjectDescription"></a>description | `string` | A verbose explanation of the parameter. [CommonMark syntax](http://spec.commonmark.org/) can be used for rich text representation.
<a name="parameterObjectSchema"></a>schema | [Schema Object](#schemaObject) | Definition of the parameter.

Expand All @@ -756,15 +828,14 @@ This object can be extended with [Specification Extensions](#specificationExtens
```json
{
"user/{userId}/signup": {
"parameters": [
{
"name": "userId",
"parameters": {
"userId": {
"description": "Id of the user.",
"schema": {
"type": "string"
}
}
],
},
"subscribe": {
"$ref": "#/components/messages/userSignedUp"
}
Expand All @@ -775,7 +846,7 @@ This object can be extended with [Specification Extensions](#specificationExtens
```yaml
user/{userId}/signup:
parameters:
- name: userId
userId:
description: Id of the user.
schema:
type: string
Expand All @@ -786,7 +857,6 @@ user/{userId}/signup:




#### <a name="protocolInfoObject"></a>Protocol Info Object

Free-form key-value object describing protocol-specific definitions for channels, operations, and messages.
Expand Down
17 changes: 5 additions & 12 deletions versions/next/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@
"$ref": "#/definitions/info"
},
"servers": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/server"
},
"uniqueItems": true
}
},
"defaultContentType": {
"type": "string"
Expand Down Expand Up @@ -572,10 +571,8 @@
"$ref": "#/definitions/ReferenceObject"
},
"parameters": {
"type": "array",
"uniqueItems": true,
"minItems": 1,
"items": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/parameter"
}
},
Expand Down Expand Up @@ -613,10 +610,6 @@
"type": "string",
"description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed."
},
"name": {
"type": "string",
"description": "The name of the parameter."
},
"schema": {
"$ref": "#/definitions/schema"
},
Expand Down