From 051562852707e14a76c38eb01d41506430d6d3f3 Mon Sep 17 00:00:00 2001 From: Animesh Kumar Date: Sat, 8 Jun 2024 20:14:46 +0530 Subject: [PATCH] fix: add comment in asyncapi.md for validation Changes: - added comments in the file as suggested by Sergio here: https://github.com/asyncapi/spec/issues/957#issuecomment-2149497548 - more comments to be adjusted according to the json format --- spec/asyncapi.md | 96 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 3 deletions(-) diff --git a/spec/asyncapi.md b/spec/asyncapi.md index 4611f3b9..b2f49899 100644 --- a/spec/asyncapi.md +++ b/spec/asyncapi.md @@ -273,6 +273,8 @@ This object MAY be extended with [Specification Extensions](#specificationExtens ##### Info Object Example + + ```json { "title": "AsyncAPI Sample App", @@ -333,8 +335,7 @@ Field Name | Type | Description This object MAY be extended with [Specification Extensions](#specificationExtensions). -##### Contact Object Example - + ```json { "name": "API Support", @@ -343,6 +344,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml name: API Support url: https://www.example.com/support @@ -362,6 +364,7 @@ Field Name | Type | Description This object MAY be extended with [Specification Extensions](#specificationExtensions). + ##### License Object Example ```json @@ -371,6 +374,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html @@ -388,6 +392,7 @@ Field Pattern | Type | Description ##### Servers Object Example + ```json { "development": { @@ -429,6 +434,7 @@ Field Pattern | Type | Description } ``` + ```yaml development: host: localhost:5672 @@ -481,6 +487,7 @@ Field Name | Type | Description A single server would be described as: + ```json { "host": "kafka.in.mycompany.com:9092", @@ -490,6 +497,7 @@ A single server would be described as: } ``` + ```yaml host: kafka.in.mycompany.com:9092 description: Production Kafka broker. @@ -499,6 +507,7 @@ protocolVersion: '3.2' An example of a server that has a `pathname`: + ```json { "host": "rabbitmq.in.mycompany.com:5672", @@ -508,6 +517,7 @@ An example of a server that has a `pathname`: } ``` + ```yaml host: rabbitmq.in.mycompany.com:5672 pathname: /production @@ -532,6 +542,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens ##### Server Variable Object Example + ```json { "host": "rabbitmq.in.mycompany.com:5672", @@ -550,6 +561,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml host: 'rabbitmq.in.mycompany.com:5672' pathname: '/{env}' @@ -571,12 +583,14 @@ In case a message can't be encoded/decoded using this value, schema parsers MUST ##### Default Content Type Example + ```json { "defaultContentType": "application/json" } ``` + ```yaml defaultContentType: application/json ``` @@ -593,6 +607,7 @@ Field Pattern | Type | Description ##### Channels Object Example + ```json { "userSignedUp": { @@ -606,6 +621,7 @@ Field Pattern | Type | Description } ``` + ```yaml userSignedUp: address: 'user.signedup' @@ -637,6 +653,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens ##### Channel Object Example + ```json { "address": "users.{userId}", @@ -678,6 +695,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml address: 'users.{userId}' title: Users channel @@ -724,6 +742,7 @@ Field Pattern | Type | Description ##### Messages Object Example + ```json { "userSignedUp": { @@ -735,6 +754,7 @@ Field Pattern | Type | Description } ``` + ```yaml userSignedUp: $ref: '#/components/messages/userSignedUp' @@ -756,6 +776,7 @@ Field Pattern | Type | Description ##### Operations Object Example + ```json { "onUserSignUp": { @@ -783,6 +804,8 @@ Field Pattern | Type | Description } ``` + + ```yaml onUserSignUp: title: User sign up @@ -825,6 +848,7 @@ Field Name | Type | Description This object MAY be extended with [Specification Extensions](#specificationExtensions). + ##### Operation Object Example ```json @@ -874,6 +898,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml title: User sign up summary: Action to sign a user up. @@ -927,6 +952,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens ##### Operation Trait Object Example + ```json { "bindings": { @@ -937,6 +963,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml bindings: amqp: @@ -974,6 +1001,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens ##### Examples + ```json { "description": "Consumer inbox", @@ -981,6 +1009,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml description: Consumer Inbox location: $message.header#/replyTo @@ -1000,6 +1029,7 @@ Field Pattern | Type | Description ##### Parameters Object Example + ```json { "address": "user/{userId}/signedup", @@ -1011,6 +1041,7 @@ Field Pattern | Type | Description } ``` + ```yaml address: user/{userId}/signedup parameters: @@ -1036,6 +1067,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens ##### Parameter Object Example + ```json { "address": "user/{userId}/signedup", @@ -1048,6 +1080,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml address: user/{userId}/signedup parameters: @@ -1200,6 +1233,7 @@ Field Name | Type | Description This object MAY be extended with [Specification Extensions](#specificationExtensions). + ##### Message Object Example ```json @@ -1266,6 +1300,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml name: UserSignup title: User signup @@ -1312,6 +1347,7 @@ examples: Example using Avro to define the payload: + ```json { "name": "UserSignup", @@ -1332,6 +1368,7 @@ Example using Avro to define the payload: } ``` + ```yaml name: UserSignup title: User signup @@ -1371,6 +1408,7 @@ Field Name | Type | Description This object MAY be extended with [Specification Extensions](#specificationExtensions). + ##### Message Trait Object Example ```json @@ -1379,6 +1417,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml contentType: application/json ``` @@ -1400,6 +1439,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens ##### Message Example Object Example + ```json { "name": "SimpleSignup", @@ -1419,6 +1459,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml name: SimpleSignup summary: A simple UserSignup example message @@ -1452,6 +1493,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens ##### Tag Object Example + ```json { "name": "user", @@ -1459,6 +1501,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml name: user description: User-related messages @@ -1479,6 +1522,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens ##### External Documentation Object Example + ```json { "description": "Find more info here", @@ -1486,6 +1530,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml description: Find more info here url: https://example.com @@ -1509,12 +1554,14 @@ This object cannot be extended with additional properties and any properties add ##### Reference Object Example + ```json { "$ref": "#/components/schemas/Pet" } ``` + ```yaml $ref: '#/components/schemas/Pet' ``` @@ -1564,6 +1611,7 @@ my.org.User ##### Components Object Example + ```json { "components": { @@ -1697,6 +1745,7 @@ my.org.User } ``` + ```yaml components: schemas: @@ -1818,6 +1867,7 @@ Name | Allowed values | Notes ###### Multi Format Schema Object Example with Avro + ```yaml channels: example: @@ -1923,6 +1973,7 @@ As such, inline schema definitions, which do not have a given id, _cannot_ be us ###### Primitive Sample + ```json { "type": "string", @@ -1930,11 +1981,13 @@ As such, inline schema definitions, which do not have a given id, _cannot_ be us } ``` + ```yaml type: string format: email ``` + ###### Simple Model ```json @@ -1959,6 +2012,7 @@ format: email } ``` + ```yaml type: object required: @@ -1978,6 +2032,7 @@ properties: For a simple string to string mapping: + ```json { "type": "object", @@ -1987,6 +2042,7 @@ For a simple string to string mapping: } ``` + ```yaml type: object additionalProperties: @@ -1995,6 +2051,7 @@ additionalProperties: For a string to model mapping: + ```json { "type": "object", @@ -2004,6 +2061,7 @@ For a string to model mapping: } ``` + ```yaml type: object additionalProperties: @@ -2012,6 +2070,7 @@ additionalProperties: ###### Model with Example + ```json { "type": "object", @@ -2036,6 +2095,7 @@ additionalProperties: } ``` + ```yaml type: object properties: @@ -2053,6 +2113,7 @@ examples: ###### Model with Boolean Schemas + ```json { "type": "object", @@ -2066,6 +2127,7 @@ examples: } ``` + ```yaml type: object required: @@ -2077,6 +2139,7 @@ properties: ###### Models with Composition + ```json { "schemas": { @@ -2119,6 +2182,7 @@ properties: } ``` + ```yaml schemas: ErrorModel: @@ -2146,6 +2210,7 @@ schemas: ###### Models with Polymorphism Support + ```json { "schemas": { @@ -2239,6 +2304,7 @@ schemas: } ``` + ```yaml schemas: Pet: @@ -2336,18 +2402,21 @@ This object MAY be extended with [Specification Extensions](#specificationExtens ###### User/Password Authentication Sample + ```json { "type": "userPassword" } ``` + ```yaml type: userPassword ``` ###### API Key Authentication Sample + ```json { "type": "apiKey", @@ -2355,6 +2424,7 @@ type: userPassword } ``` + ```yaml type: apiKey in: user @@ -2362,30 +2432,35 @@ in: user ###### X.509 Authentication Sample + ```json { "type": "X509" } ``` + ```yaml type: X509 ``` ###### End-to-end Encryption Authentication Sample + ```json { "type": "symmetricEncryption" } ``` + ```yaml type: symmetricEncryption ``` ###### Basic Authentication Sample + ```json { "type": "http", @@ -2393,6 +2468,7 @@ type: symmetricEncryption } ``` + ```yaml type: http scheme: basic @@ -2400,6 +2476,7 @@ scheme: basic ###### API Key Sample + ```json { "type": "httpApiKey", @@ -2408,6 +2485,7 @@ scheme: basic } ``` + ```yaml type: httpApiKey name: api_key @@ -2416,6 +2494,7 @@ in: header ###### JWT Bearer Sample + ```json { "type": "http", @@ -2424,6 +2503,7 @@ in: header } ``` + ```yaml type: http scheme: bearer @@ -2432,6 +2512,7 @@ bearerFormat: JWT ###### Implicit OAuth2 Sample + ```json { "type": "oauth2", @@ -2450,6 +2531,7 @@ bearerFormat: JWT } ``` + ```yaml type: oauth2 flows: @@ -2464,12 +2546,14 @@ scopes: ###### SASL Sample + ```json { "type": "scramSha512" } ``` + ```yaml type: scramSha512 ``` @@ -2506,6 +2590,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens ##### OAuth Flow Object Examples + ```JSON { "authorizationUrl": "https://example.com/api/oauth/dialog", @@ -2517,6 +2602,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```YAML authorizationUrl: https://example.com/api/oauth/dialog tokenUrl: https://example.com/api/oauth/token @@ -2542,6 +2628,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens ##### Examples + ```json { "description": "Default Correlation ID", @@ -2549,6 +2636,7 @@ This object MAY be extended with [Specification Extensions](#specificationExtens } ``` + ```yaml description: Default Correlation ID location: $message.header#/correlationId @@ -2588,6 +2676,7 @@ Traits MUST be merged with the target object using the [JSON Merge Patch](https: An object like the following: + ```yaml description: A longer description. traits: @@ -2599,6 +2688,7 @@ traits: Would look like the following after applying traits: + ```yaml name: UserSignup description: A longer description. @@ -2641,4 +2731,4 @@ binary | `string` | `binary` | any sequence of octets boolean | `boolean` | | | date | `string` | `date` | As defined by `full-date` - [RFC3339](https://www.rfc-editor.org/rfc/rfc3339.html#section-5.6) dateTime | `string` | `date-time` | As defined by `date-time` - [RFC3339](https://www.rfc-editor.org/rfc/rfc3339.html#section-5.6) -password | `string` | `password` | Used to hint UIs the input needs to be obscured. +password | `string` | `password` | Used to hint UIs the input needs to be obscured. \ No newline at end of file