diff --git a/.gitignore b/.gitignore index d4a20833..fc668545 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ node_modules .nyc_output .vscode -coverage \ No newline at end of file +coverage + +.DS_Store \ No newline at end of file diff --git a/definitions/3.0.0/components.json b/definitions/3.0.0/components.json index 2d7b5e2f..2243d978 100644 --- a/definitions/3.0.0/components.json +++ b/definitions/3.0.0/components.json @@ -13,14 +13,7 @@ "description": "An object to hold reusable Schema Object. If this is a Schema Object, then the schemaFormat will be assumed to be 'application/vnd.aai.asyncapi+json;version=asyncapi' where the version is equal to the AsyncAPI Version String.", "patternProperties": { "^[\\w\\d\\.\\-_]+$": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json" - } - ] + "$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json" } } }, diff --git a/definitions/3.0.0/multiFormatSchema.json b/definitions/3.0.0/multiFormatSchema.json index d4047bb0..077cdcf6 100644 --- a/definitions/3.0.0/multiFormatSchema.json +++ b/definitions/3.0.0/multiFormatSchema.json @@ -1,5 +1,11 @@ { "description": "The Multi Format Schema Object represents a schema definition. It differs from the Schema Object in that it supports multiple schema formats or languages (e.g., JSON Schema, Avro, etc.).", + "type": "object", + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" + } + }, "if": { "not": { "type": "object" @@ -9,13 +15,6 @@ "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" }, "else": { - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^x-[\\w\\d\\.\\x2d_]+$": { - "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" - } - }, "properties": { "schemaFormat": { "description": "A string containing the name of the schema format that is used to define the information. If schemaFormat is missing, it MUST default to application/vnd.aai.asyncapi+json;version={{asyncapi}} where {{asyncapi}} matches the AsyncAPI Version String. In such a case, this would make the Multi Format Schema Object equivalent to the Schema Object. When using Reference Object within the schema, the schemaFormat of the resource being referenced MUST match the schemaFormat of the schema that contains the initial reference. For example, if you reference Avro schema, then schemaFormat of referencing resource and the resource being reference MUST match.", @@ -37,21 +36,18 @@ { "description": "All the schema formats tools are RECOMMENDED to support", "enum": [ - "application/vnd.oai.openapi;version=3.0.0", - "application/vnd.oai.openapi+json;version=3.0.0", + "application/vnd.oai.openapi;version=3.0.0", + "application/vnd.oai.openapi+json;version=3.0.0", "application/vnd.oai.openapi+yaml;version=3.0.0", - + "application/vnd.apache.avro;version=1.9.0", "application/vnd.apache.avro+json;version=1.9.0", "application/vnd.apache.avro+yaml;version=1.9.0", - + "application/raml+yaml;version=1.0" ] } ] - }, - "schema": { - "description": "Definition of the message payload. It can be of any type but defaults to Schema Object. It MUST match the schema format defined in schemaFormat, including the encoding type. E.g., Avro should be inlined as either a YAML or JSON object instead of as a string to be parsed as YAML or JSON. Non-JSON-based schemas (e.g., Protobuf or XSD) MUST be inlined as a string." } }, "allOf": [ @@ -67,14 +63,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" - } - ] + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" } } } @@ -119,14 +108,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" - } - ] + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" } } } @@ -148,14 +130,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://json-schema.org/draft-07/schema" - } - ] + "$ref": "http://json-schema.org/draft-07/schema" } } } diff --git a/schemas/3.0.0-without-$id.json b/schemas/3.0.0-without-$id.json index 34f23ee4..297899e2 100644 --- a/schemas/3.0.0-without-$id.json +++ b/schemas/3.0.0-without-$id.json @@ -2056,7 +2056,7 @@ "properties": { "type": "array", "items": { - "$ref": "#/definitions/bindings-jms-0.0.1-server" + "$ref": "#/definitions/bindings-jms-0.0.1-server/definitions/property" }, "description": "Additional properties to set on the JMS ConnectionFactory implementation for the JMS Provider." }, @@ -2702,6 +2702,12 @@ }, "multiFormatSchema": { "description": "The Multi Format Schema Object represents a schema definition. It differs from the Schema Object in that it supports multiple schema formats or languages (e.g., JSON Schema, Avro, etc.).", + "type": "object", + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "#/definitions/specificationExtension" + } + }, "if": { "not": { "type": "object" @@ -2711,13 +2717,6 @@ "$ref": "#/definitions/schema" }, "else": { - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^x-[\\w\\d\\.\\x2d_]+$": { - "$ref": "#/definitions/specificationExtension" - } - }, "properties": { "schemaFormat": { "description": "A string containing the name of the schema format that is used to define the information. If schemaFormat is missing, it MUST default to application/vnd.aai.asyncapi+json;version={{asyncapi}} where {{asyncapi}} matches the AsyncAPI Version String. In such a case, this would make the Multi Format Schema Object equivalent to the Schema Object. When using Reference Object within the schema, the schemaFormat of the resource being referenced MUST match the schemaFormat of the schema that contains the initial reference. For example, if you reference Avro schema, then schemaFormat of referencing resource and the resource being reference MUST match.", @@ -2748,9 +2747,6 @@ ] } ] - }, - "schema": { - "description": "Definition of the message payload. It can be of any type but defaults to Schema Object. It MUST match the schema format defined in schemaFormat, including the encoding type. E.g., Avro should be inlined as either a YAML or JSON object instead of as a string to be parsed as YAML or JSON. Non-JSON-based schemas (e.g., Protobuf or XSD) MUST be inlined as a string." } }, "allOf": [ @@ -2766,14 +2762,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "#/definitions/Reference" - }, - { - "$ref": "#/definitions/schema" - } - ] + "$ref": "#/definitions/schema" } } } @@ -2818,14 +2807,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "#/definitions/Reference" - }, - { - "$ref": "#/definitions/schema" - } - ] + "$ref": "#/definitions/schema" } } } @@ -2847,14 +2829,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "#/definitions/Reference" - }, - { - "$ref": "#/definitions/json-schema-draft-07-schema" - } - ] + "$ref": "#/definitions/json-schema-draft-07-schema" } } } @@ -5719,10 +5694,10 @@ "description": "The name of the topic. Can be different from the channel name to allow flexibility around AWS resource naming limitations." }, "ordering": { - "$ref": "#/definitions/bindings-sns-0.1.0-channel" + "$ref": "#/definitions/bindings-sns-0.1.0-channel/definitions/ordering" }, "policy": { - "$ref": "#/definitions/bindings-sns-0.1.0-channel" + "$ref": "#/definitions/bindings-sns-0.1.0-channel/definitions/policy" }, "tags": { "type": "object", @@ -5777,7 +5752,7 @@ "type": "array", "description": "An array of statement objects, each of which controls a permission for this topic", "items": { - "$ref": "#/definitions/bindings-sns-0.1.0-channel" + "$ref": "#/definitions/bindings-sns-0.1.0-channel/definitions/statement" } } }, @@ -5864,11 +5839,11 @@ "properties": { "queue": { "description": "A definition of the queue that will be used as the channel.", - "$ref": "#/definitions/bindings-sqs-0.2.0-channel" + "$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/queue" }, "deadLetterQueue": { "description": "A definition of the queue that will be used for un-processable messages.", - "$ref": "#/definitions/bindings-sqs-0.2.0-channel" + "$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/queue" }, "bindingVersion": { "type": "string", @@ -5947,10 +5922,10 @@ "default": 345600 }, "redrivePolicy": { - "$ref": "#/definitions/bindings-sqs-0.2.0-channel" + "$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/redrivePolicy" }, "policy": { - "$ref": "#/definitions/bindings-sqs-0.2.0-channel" + "$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/policy" }, "tags": { "type": "object", @@ -5972,7 +5947,7 @@ }, "properties": { "deadLetterQueue": { - "$ref": "#/definitions/bindings-sqs-0.2.0-channel" + "$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/identifier" }, "maxReceiveCount": { "type": "integer", @@ -6016,7 +5991,7 @@ "type": "array", "description": "An array of statement objects, each of which controls a permission for this queue.", "items": { - "$ref": "#/definitions/bindings-sqs-0.2.0-channel" + "$ref": "#/definitions/bindings-sqs-0.2.0-channel/definitions/statement" } } }, @@ -7638,19 +7613,19 @@ }, "properties": { "topic": { - "$ref": "#/definitions/bindings-sns-0.1.0-operation", + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/identifier", "description": "Often we can assume that the SNS Topic is the channel name-we provide this field in case the you need to supply the ARN, or the Topic name is not the channel name in the AsyncAPI document." }, "consumers": { "type": "array", "description": "The protocols that listen to this topic and their endpoints.", "items": { - "$ref": "#/definitions/bindings-sns-0.1.0-operation" + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/consumer" }, "minItems": 1 }, "deliveryPolicy": { - "$ref": "#/definitions/bindings-sns-0.1.0-operation", + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/deliveryPolicy", "description": "Policy for retries to HTTP. The field is the default for HTTP receivers of the SNS Topic which may be overridden by a specific consumer." }, "bindingVersion": { @@ -7718,7 +7693,7 @@ }, "endpoint": { "description": "The endpoint messages are delivered to.", - "$ref": "#/definitions/bindings-sns-0.1.0-operation" + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/identifier" }, "filterPolicy": { "type": "object", @@ -7759,10 +7734,10 @@ "description": "If true AWS SNS attributes are removed from the body, and for SQS, SNS message attributes are copied to SQS message attributes. If false the SNS attributes are included in the body." }, "redrivePolicy": { - "$ref": "#/definitions/bindings-sns-0.1.0-operation" + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/redrivePolicy" }, "deliveryPolicy": { - "$ref": "#/definitions/bindings-sns-0.1.0-operation", + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/deliveryPolicy", "description": "Policy for retries to HTTP. The parameter is for that SNS Subscription and overrides any policy on the SNS Topic." }, "displayName": { @@ -7834,7 +7809,7 @@ }, "properties": { "deadLetterQueue": { - "$ref": "#/definitions/bindings-sns-0.1.0-operation", + "$ref": "#/definitions/bindings-sns-0.1.0-operation/definitions/identifier", "description": "The SQS queue to use as a dead letter queue (DLQ)." }, "maxReceiveCount": { @@ -7912,7 +7887,7 @@ "type": "array", "description": "Queue objects that are either the endpoint for an SNS Operation Binding Object, or the deadLetterQueue of the SQS Operation Binding Object.", "items": { - "$ref": "#/definitions/bindings-sqs-0.2.0-operation" + "$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/queue" } }, "bindingVersion": { @@ -7996,10 +7971,10 @@ "default": 345600 }, "redrivePolicy": { - "$ref": "#/definitions/bindings-sqs-0.2.0-operation" + "$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/redrivePolicy" }, "policy": { - "$ref": "#/definitions/bindings-sqs-0.2.0-operation" + "$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/policy" }, "tags": { "type": "object", @@ -8020,7 +7995,7 @@ }, "properties": { "deadLetterQueue": { - "$ref": "#/definitions/bindings-sqs-0.2.0-operation" + "$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/identifier" }, "maxReceiveCount": { "type": "integer", @@ -8064,7 +8039,7 @@ "type": "array", "description": "An array of statement objects, each of which controls a permission for this queue.", "items": { - "$ref": "#/definitions/bindings-sqs-0.2.0-operation" + "$ref": "#/definitions/bindings-sqs-0.2.0-operation/definitions/statement" } } }, @@ -8516,14 +8491,7 @@ "description": "An object to hold reusable Schema Object. If this is a Schema Object, then the schemaFormat will be assumed to be 'application/vnd.aai.asyncapi+json;version=asyncapi' where the version is equal to the AsyncAPI Version String.", "patternProperties": { "^[\\w\\d\\.\\-_]+$": { - "oneOf": [ - { - "$ref": "#/definitions/Reference" - }, - { - "$ref": "#/definitions/anySchema" - } - ] + "$ref": "#/definitions/anySchema" } } }, diff --git a/schemas/3.0.0.json b/schemas/3.0.0.json index 32d55118..25bbc016 100644 --- a/schemas/3.0.0.json +++ b/schemas/3.0.0.json @@ -2753,6 +2753,12 @@ "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json": { "$id": "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json", "description": "The Multi Format Schema Object represents a schema definition. It differs from the Schema Object in that it supports multiple schema formats or languages (e.g., JSON Schema, Avro, etc.).", + "type": "object", + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" + } + }, "if": { "not": { "type": "object" @@ -2762,13 +2768,6 @@ "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" }, "else": { - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^x-[\\w\\d\\.\\x2d_]+$": { - "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" - } - }, "properties": { "schemaFormat": { "description": "A string containing the name of the schema format that is used to define the information. If schemaFormat is missing, it MUST default to application/vnd.aai.asyncapi+json;version={{asyncapi}} where {{asyncapi}} matches the AsyncAPI Version String. In such a case, this would make the Multi Format Schema Object equivalent to the Schema Object. When using Reference Object within the schema, the schemaFormat of the resource being referenced MUST match the schemaFormat of the schema that contains the initial reference. For example, if you reference Avro schema, then schemaFormat of referencing resource and the resource being reference MUST match.", @@ -2799,9 +2798,6 @@ ] } ] - }, - "schema": { - "description": "Definition of the message payload. It can be of any type but defaults to Schema Object. It MUST match the schema format defined in schemaFormat, including the encoding type. E.g., Avro should be inlined as either a YAML or JSON object instead of as a string to be parsed as YAML or JSON. Non-JSON-based schemas (e.g., Protobuf or XSD) MUST be inlined as a string." } }, "allOf": [ @@ -2817,14 +2813,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" - } - ] + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" } } } @@ -2869,14 +2858,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" - } - ] + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" } } } @@ -2898,14 +2880,7 @@ "then": { "properties": { "schema": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://json-schema.org/draft-07/schema" - } - ] + "$ref": "http://json-schema.org/draft-07/schema" } } } @@ -8618,14 +8593,7 @@ "description": "An object to hold reusable Schema Object. If this is a Schema Object, then the schemaFormat will be assumed to be 'application/vnd.aai.asyncapi+json;version=asyncapi' where the version is equal to the AsyncAPI Version String.", "patternProperties": { "^[\\w\\d\\.\\-_]+$": { - "oneOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - }, - { - "$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json" - } - ] + "$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json" } } }, diff --git a/test/docs/3.0.0/streetlights-all.json b/test/docs/3.0.0/streetlights-all.json index 15b7cdc6..e0e3e781 100644 --- a/test/docs/3.0.0/streetlights-all.json +++ b/test/docs/3.0.0/streetlights-all.json @@ -6,7 +6,53 @@ "description": "This service is in charge of processing user signups" }, "channels": { - "UserSignedUpChannel": { + "AsyncAPI-UserSignedUpChannel": { + "address": "user/signedup/{test_param}", + "parameters": { + "test_param": { + "enum": [ + "test" + ], + "default": "test", + "description": "Just a test description", + "examples": [ + "test" + ], + "location": "$message.payload#", + "x-custom-extension": "test" + } + }, + "messages": { + "AsyncAPI-UserSignedUp": { + "$ref": "#/components/messages/AsyncAPI-UserSignedUp" + } + } + }, + "Avro-UserSignedUpChannel": { + "address": "user/signedup", + "messages": { + "UserSignedUp": { + "$ref": "#/components/messages/Avro-UserSignedUp" + } + } + }, + "Json-UserSignedUpChannel": { + "address": "user/signedup", + "messages": { + "UserSignedUp": { + "$ref": "#/components/messages/Json-UserSignedUp" + } + } + }, + "OpenAPI-UserSignedUpChannel": { + "address": "user/signedup", + "messages": { + "UserSignedUp": { + "$ref": "#/components/messages/OpenAPI-UserSignedUp" + } + } + }, + "Unknown-UserSignedUpChannel": { "address": "user/signedup/{test_param}", "parameters": { "test_param": { @@ -24,16 +70,96 @@ }, "messages": { "UserSignedUp": { - "$ref": "#/components/messages/UserSignedUp" + "$ref": "#/components/messages/Unknown-UserSignedUp" } } } }, "operations": { - "PublishUserSignedUp": { + "AsyncAPI-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/AsyncAPI-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "AsyncAPI-PublishUserSignedUpDefaultBinding": { + "action": "send", + "channel": { + "$ref": "#/channels/AsyncAPI-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Avro-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/Avro-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Avro-PublishUserSignedUpDefaultBinding": { "action": "send", "channel": { - "$ref": "#/channels/UserSignedUpChannel" + "$ref": "#/channels/Avro-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Json-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/Json-UserSignedUpChannel" }, "bindings": { "mqtt": { @@ -51,10 +177,90 @@ } } }, - "PublishUserSignedUpDefaultBinding": { + "Json-PublishUserSignedUpDefaultBinding": { "action": "send", "channel": { - "$ref": "#/channels/UserSignedUpChannel" + "$ref": "#/channels/Json-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "OpenAPI-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/OpenAPI-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "OpenAPI-PublishUserSignedUpDefaultBinding": { + "action": "send", + "channel": { + "$ref": "#/channels/OpenAPI-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Unknown-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/Unknown-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Unknown-PublishUserSignedUpDefaultBinding": { + "action": "send", + "channel": { + "$ref": "#/channels/Unknown-UserSignedUpChannel" }, "bindings": { "mqtt": { @@ -72,8 +278,85 @@ } }, "components": { + "schemas": { + "Avro-UserSignedUpHeaders": { + "schemaFormat": "application/vnd.apache.avro;version=1.9.0", + "schema": { + "fields": [ + { + "name": "applicationInstanceId", + "type": "string" + }, + { + "name": "correlationId", + "type": "string" + } + ], + "name": "UserSignedUpHeaders", + "namespace": "com.example.avro", + "type": "record" + } + }, + "Avro-ReferencedSchema": { + "schemaFormat": "application/vnd.apache.avro;version=1.9.0", + "schema": { + "$ref": "reference-to-some-avro-file.avsc" + } + }, + "Json-UserSignedUpHeaders": { + "schemaFormat": "application/schema+json;version=draft-07", + "schema": { + "type": "object", + "properties": { + "applicationInstanceId": { + "type": "string", + "description": "Application instance Id" + }, + "correlationId": { + "type": "string", + "description": "Correlation Id" + } + } + } + }, + "Json-ReferencedSchema": { + "schemaFormat": "application/schema+json;version=draft-07", + "schema": { + "$ref": "reference-to-some-json-schema-file.json" + } + }, + "OpenAPI-ReferencedSchema": { + "schemaFormat": "application/vnd.oai.openapi;version=3.0.0", + "schema": { + "$ref": "reference-to-some-openapi-file.json" + } + } + }, "messages": { - "UserSignedUp": { + "AsyncAPI-UserSignedUp": { + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "type": "object", + "properties": { + "displayName": { + "type": "string", + "description": "Name of the user" + }, + "email": { + "type": "string", + "format": "email", + "description": "Email of the user" + } + }, + "externalDocs": { + "url": "https://account-service/docs/UserSignedUp" + }, + "deprecated": false + } + } + }, + "AsyncAPI-UserSignedUpV2": { "payload": { "type": "object", "properties": { @@ -86,10 +369,398 @@ "format": "email", "description": "Email of the user" } + }, + "externalDocs": { + "url": "https://account-service/docs/UserSignedUp" + }, + "deprecated": false + } + }, + "AsyncAPI-UserSignedUpV3": { + "payload": { + "$ref": "external-schema.json" + } + }, + "Avro-UserSignedUp": { + "headers": { + "$ref": "#/components/schemas/Avro-UserSignedUpHeaders" + }, + "payload": { + "schemaFormat": "application/vnd.apache.avro;version=1.9.0", + "schema": { + "doc": "This is a user record in a fictitious to-do-list management app. It supports arbitrary grouping and nesting of items, and allows you to add items by email or by tweeting.\n\nNote this app doesn't actually exist. The schema is just a demo for [Avrodoc](https://github.com/ept/avrodoc)!", + "fields": [ + { + "name": "id", + "doc": "System-assigned numeric user ID. Cannot be changed by the user.", + "type": "int" + }, + { + "name": "username", + "doc": "The username chosen by the user. Can be changed by the user.", + "type": "string" + }, + { + "name": "passwordHash", + "doc": "The user's password, hashed using [scrypt](http://www.tarsnap.com/scrypt.html).", + "type": "string" + }, + { + "name": "signupDate", + "doc": "Timestamp (milliseconds since epoch) when the user signed up", + "type": "long" + }, + { + "name": "emailAddresses", + "doc": "All email addresses on the user's account", + "type": { + "type": "array", + "items": { + "type": "record", + "name": "EmailAddress", + "doc": "Stores details about an email address that a user has associated with their account.", + "fields": [ + { + "name": "address", + "doc": "The email address, e.g. `foo@example.com`", + "type": "string" + }, + { + "name": "verified", + "doc": "true if the user has clicked the link in a confirmation email to this address.", + "type": "boolean", + "default": false + }, + { + "name": "dateAdded", + "doc": "Timestamp (milliseconds since epoch) when the email address was added to the account.", + "type": "long" + }, + { + "name": "dateBounced", + "doc": "Timestamp (milliseconds since epoch) when an email sent to this address last bounced. Reset to null when the address no longer bounces.", + "type": [ + "null", + "long" + ] + } + ] + } + } + }, + { + "name": "twitterAccounts", + "doc": "All Twitter accounts that the user has OAuthed", + "type": { + "type": "array", + "items": { + "type": "record", + "name": "TwitterAccount", + "doc": "Stores access credentials for one Twitter account, as granted to us by the user by OAuth.", + "fields": [ + { + "name": "status", + "doc": "Indicator of whether this authorization is currently active, or has been revoked", + "type": { + "type": "enum", + "name": "OAuthStatus", + "doc": "* `PENDING`: the user has started authorizing, but not yet finished\n* `ACTIVE`: the token should work\n* `DENIED`: the user declined the authorization\n* `EXPIRED`: the token used to work, but now it doesn't\n* `REVOKED`: the user has explicitly revoked the token", + "symbols": [ + "PENDING", + "ACTIVE", + "DENIED", + "EXPIRED", + "REVOKED" + ] + } + }, + { + "name": "userId", + "doc": "Twitter's numeric ID for this user", + "type": "long" + }, + { + "name": "screenName", + "doc": "The twitter username for this account (can be changed by the user)", + "type": "string" + }, + { + "name": "oauthToken", + "doc": "The OAuth token for this Twitter account", + "type": "string" + }, + { + "name": "oauthTokenSecret", + "doc": "The OAuth secret, used for signing requests on behalf of this Twitter account. `null` whilst the OAuth flow is not yet complete.", + "type": [ + "null", + "string" + ] + }, + { + "name": "dateAuthorized", + "doc": "Timestamp (milliseconds since epoch) when the user last authorized this Twitter account", + "type": "long" + } + ] + } + } + }, + { + "name": "toDoItems", + "doc": "The top-level items in the user's to-do list", + "type": { + "type": "array", + "items": { + "type": "record", + "name": "ToDoItem", + "doc": "A record is one node in a To-Do item tree (every record can contain nested sub-records).", + "fields": [ + { + "name": "status", + "doc": "User-selected state for this item (e.g. whether or not it is marked as done)", + "type": { + "type": "enum", + "name": "ToDoStatus", + "doc": "* `HIDDEN`: not currently visible, e.g. because it becomes actionable in future\n* `ACTIONABLE`: appears in the current to-do list\n* `DONE`: marked as done, but still appears in the list\n* `ARCHIVED`: marked as done and no longer visible\n* `DELETED`: not done and removed from list (preserved for undo purposes)", + "symbols": [ + "HIDDEN", + "ACTIONABLE", + "DONE", + "ARCHIVED", + "DELETED" + ] + } + }, + { + "name": "title", + "doc": "One-line summary of the item", + "type": "string" + }, + { + "name": "description", + "doc": "Detailed description (may contain HTML markup)", + "type": [ + "null", + "string" + ] + }, + { + "name": "snoozeDate", + "doc": "Timestamp (milliseconds since epoch) at which the item should go from `HIDDEN` to `ACTIONABLE` status", + "type": [ + "null", + "long" + ] + }, + { + "name": "subItems", + "doc": "List of children of this to-do tree node", + "type": { + "type": "array", + "items": "ToDoItem" + } + } + ] + } + } + } + ], + "name": "User", + "namespace": "com.example.avro", + "type": "record" + } + } + }, + "Json-UserSignedUp": { + "headers": { + "$ref": "#/components/schemas/Json-UserSignedUpHeaders" + }, + "payload": { + "schemaFormat": "application/schema+json;version=draft-07", + "schema": { + "type": "object", + "description": "This is a user record in a fictitious to-do-list management app. It supports arbitrary grouping and nesting of items, and allows you to add items by email or by tweeting.\n\nNote this app doesn't actually exist. The schema is just a demo for [Avrodoc](https://github.com/ept/avrodoc)!", + "properties": { + "id": { + "type": "integer", + "description": "System-assigned numeric user ID. Cannot be changed by the user." + }, + "username": { + "type": "string", + "description": "The username chosen by the user. Can be changed by the user." + }, + "passwordHash": { + "type": "string", + "description": "The user's password, hashed using [scrypt](http://www.tarsnap.com/scrypt.html)." + }, + "signupDate": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when the user signed up" + }, + "emailAddresses": { + "type": "array", + "description": "All email addresses on the user's account", + "items": { + "type": "object", + "description": "Stores details about an email address that a user has associated with their account.", + "properties": { + "address": { + "type": "string", + "description": "The email address, e.g. `foo@example.com`" + }, + "verified": { + "type": "boolean", + "description": "true if the user has clicked the link in a confirmation email to this address.", + "default": false + }, + "dateAdded": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when the email address was added to the account." + }, + "dateBounced": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when an email sent to this address last bounced. Reset to null when the address no longer bounces." + } + } + } + }, + "twitterAccounts": { + "type": "array", + "description": "All Twitter accounts that the user has OAuthed", + "items": { + "type": "object", + "description": "Stores access credentials for one Twitter account, as granted to us by the user by OAuth.", + "properties": { + "status": { + "type": "string", + "description": "Indicator of whether this authorization is currently active, or has been revoked", + "enum": [ + "PENDING", + "ACTIVE", + "DENIED", + "EXPIRED", + "REVOKED" + ] + }, + "userId": { + "type": "number", + "description": "Twitter's numeric ID for this user" + }, + "screenName": { + "type": "string", + "description": "The twitter username for this account (can be changed by the user)" + }, + "oauthToken": { + "type": "string", + "description": "The OAuth token for this Twitter account" + }, + "oauthTokenSecret": { + "type": "string", + "description": "The OAuth secret, used for signing requests on behalf of this Twitter account. `null` whilst the OAuth flow is not yet complete." + }, + "dateAuthorized": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when the user last authorized this Twitter account" + } + } + } + }, + "toDoItems": { + "type": "array", + "items": { + "type": "object", + "description": "A record is one node in a To-Do item tree (every record can contain nested sub-records).", + "properties": { + "status": { + "type": "string", + "description": "User-selected state for this item (e.g. whether or not it is marked as done)", + "enum": [ + "HIDDEN", + "ACTIONABLE", + "DONE", + "ARCHIVED", + "DELETED" + ] + }, + "title": { + "type": "string", + "description": "One-line summary of the item" + }, + "description": { + "type": "string", + "description": "Detailed description (may contain HTML markup)" + }, + "snoozeDate": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) at which the item should go from `HIDDEN` to `ACTIONABLE` status" + }, + "subItems": { + "type": "array", + "doc": "List of children of this to-do tree node", + "items": { + "$ref": "#/components/messages/UserSignedUp/payload/schema/properties/toDoItems" + } + } + } + } + } + } + } + } + }, + "OpenAPI-UserSignedUp": { + "payload": { + "schemaFormat": "application/vnd.oai.openapi;version=3.0.0", + "schema": { + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + }, + "completed": { + "type": "boolean" + }, + "completed_at": { + "type": "string", + "format": "date-time", + "nullable": true + } + }, + "required": [ + "id", + "name", + "completed" + ] + } + } + }, + "Unknown-UserSignedUp": { + "payload": { + "schemaFormat": "unknown-schema-format", + "schema": { + "type": "object", + "properties": { + "displayName": { + "type": "string", + "description": "Name of the user" + }, + "email": { + "type": "string", + "format": "email", + "description": "Email of the user" + } + }, + "externalDocs": { + "url": "https://account-service/docs/UserSignedUp" + }, + "deprecated": false } } }, - "UserSignedUpV2": { + "Unknown-UserSignedUpV2": { "payload": { "$ref": "external-schema.json" } diff --git a/test/docs/3.0.0/streetlights-asyncapi.json b/test/docs/3.0.0/streetlights-asyncapi.json new file mode 100644 index 00000000..c6885a2e --- /dev/null +++ b/test/docs/3.0.0/streetlights-asyncapi.json @@ -0,0 +1,126 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Account Service", + "version": "1.0.0", + "description": "This service is in charge of processing user signups" + }, + "channels": { + "AsyncAPI-UserSignedUpChannel": { + "address": "user/signedup/{test_param}", + "parameters": { + "test_param": { + "enum": [ + "test" + ], + "default": "test", + "description": "Just a test description", + "examples": [ + "test" + ], + "location": "$message.payload#", + "x-custom-extension": "test" + } + }, + "messages": { + "AsyncAPI-UserSignedUp": { + "$ref": "#/components/messages/AsyncAPI-UserSignedUp" + } + } + } + }, + "operations": { + "AsyncAPI-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/AsyncAPI-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "AsyncAPI-PublishUserSignedUpDefaultBinding": { + "action": "send", + "channel": { + "$ref": "#/channels/AsyncAPI-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + } + }, + "components": { + "messages": { + "AsyncAPI-UserSignedUp": { + "payload": { + "schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0", + "schema": { + "type": "object", + "properties": { + "displayName": { + "type": "string", + "description": "Name of the user" + }, + "email": { + "type": "string", + "format": "email", + "description": "Email of the user" + } + }, + "externalDocs": { + "url": "https://account-service/docs/UserSignedUp" + }, + "deprecated": false + } + } + }, + "AsyncAPI-UserSignedUpV2": { + "payload": { + "type": "object", + "properties": { + "displayName": { + "type": "string", + "description": "Name of the user" + }, + "email": { + "type": "string", + "format": "email", + "description": "Email of the user" + } + }, + "externalDocs": { + "url": "https://account-service/docs/UserSignedUp" + }, + "deprecated": false + } + }, + "AsyncAPI-UserSignedUpV3": { + "payload": { + "$ref": "external-schema.json" + } + } + } + } +} \ No newline at end of file diff --git a/test/docs/3.0.0/streetlights-avro.json b/test/docs/3.0.0/streetlights-avro.json index 34eed135..4396022b 100644 --- a/test/docs/3.0.0/streetlights-avro.json +++ b/test/docs/3.0.0/streetlights-avro.json @@ -6,20 +6,20 @@ "description": "This service is in charge of processing user signups" }, "channels": { - "UserSignedUpChannel": { + "Avro-UserSignedUpChannel": { "address": "user/signedup", "messages": { "UserSignedUp": { - "$ref": "#/components/messages/UserSignedUp" + "$ref": "#/components/messages/Avro-UserSignedUp" } } } }, "operations": { - "PublishUserSignedUp": { + "Avro-PublishUserSignedUp": { "action": "send", "channel": { - "$ref": "#/channels/UserSignedUpChannel" + "$ref": "#/channels/Avro-UserSignedUpChannel" }, "bindings": { "mqtt": { @@ -37,10 +37,10 @@ } } }, - "PublishUserSignedUpDefaultBinding": { + "Avro-PublishUserSignedUpDefaultBinding": { "action": "send", "channel": { - "$ref": "#/channels/UserSignedUpChannel" + "$ref": "#/channels/Avro-UserSignedUpChannel" }, "bindings": { "mqtt": { @@ -59,7 +59,7 @@ }, "components": { "schemas": { - "UserSignedUpHeaders": { + "Avro-UserSignedUpHeaders": { "schemaFormat": "application/vnd.apache.avro;version=1.9.0", "schema": { "fields": [ @@ -77,7 +77,7 @@ "type": "record" } }, - "ReferencedSchema" : { + "Avro-ReferencedSchema" : { "schemaFormat": "application/vnd.apache.avro;version=1.9.0", "schema": { "$ref": "reference-to-some-avro-file.avsc" @@ -85,9 +85,9 @@ } }, "messages": { - "UserSignedUp": { + "Avro-UserSignedUp": { "headers": { - "$ref": "#/components/schemas/UserSignedUpHeaders" + "$ref": "#/components/schemas/Avro-UserSignedUpHeaders" }, "payload": { "schemaFormat": "application/vnd.apache.avro;version=1.9.0", diff --git a/test/docs/3.0.0/streetlights-json.json b/test/docs/3.0.0/streetlights-json.json new file mode 100644 index 00000000..61b96152 --- /dev/null +++ b/test/docs/3.0.0/streetlights-json.json @@ -0,0 +1,225 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Account Service", + "version": "1.0.0", + "description": "This service is in charge of processing user signups" + }, + "channels": { + "Json-UserSignedUpChannel": { + "address": "user/signedup", + "messages": { + "UserSignedUp": { + "$ref": "#/components/messages/Json-UserSignedUp" + } + } + } + }, + "operations": { + "Json-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/Json-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Json-PublishUserSignedUpDefaultBinding": { + "action": "send", + "channel": { + "$ref": "#/channels/Json-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + } + }, + "components": { + "schemas": { + "Json-UserSignedUpHeaders": { + "schemaFormat": "application/schema+json;version=draft-07", + "schema": { + "type": "object", + "properties": { + "applicationInstanceId": { + "type": "string", + "description": "Application instance Id" + }, + "correlationId": { + "type": "string", + "description": "Correlation Id" + } + } + } + }, + "Json-ReferencedSchema" : { + "schemaFormat": "application/schema+json;version=draft-07", + "schema": { + "$ref": "reference-to-some-json-schema-file.json" + } + } + }, + "messages": { + "Json-UserSignedUp": { + "headers": { + "$ref": "#/components/schemas/Json-UserSignedUpHeaders" + }, + "payload": { + "schemaFormat": "application/schema+json;version=draft-07", + "schema": { + "type": "object", + "description": "This is a user record in a fictitious to-do-list management app. It supports arbitrary grouping and nesting of items, and allows you to add items by email or by tweeting.\n\nNote this app doesn't actually exist. The schema is just a demo for [Avrodoc](https://github.com/ept/avrodoc)!", + "properties": { + "id": { + "type": "integer", + "description": "System-assigned numeric user ID. Cannot be changed by the user." + }, + "username": { + "type": "string", + "description": "The username chosen by the user. Can be changed by the user." + }, + "passwordHash": { + "type": "string", + "description": "The user's password, hashed using [scrypt](http://www.tarsnap.com/scrypt.html)." + }, + "signupDate": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when the user signed up" + }, + "emailAddresses": { + "type": "array", + "description": "All email addresses on the user's account", + "items": { + "type": "object", + "description": "Stores details about an email address that a user has associated with their account.", + "properties": { + "address": { + "type": "string", + "description": "The email address, e.g. `foo@example.com`" + }, + "verified": { + "type": "boolean", + "description": "true if the user has clicked the link in a confirmation email to this address.", + "default": false + }, + "dateAdded": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when the email address was added to the account." + }, + "dateBounced": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when an email sent to this address last bounced. Reset to null when the address no longer bounces." + } + } + } + }, + "twitterAccounts": { + "type": "array", + "description": "All Twitter accounts that the user has OAuthed", + "items": { + "type": "object", + "description": "Stores access credentials for one Twitter account, as granted to us by the user by OAuth.", + "properties": { + "status": { + "type": "string", + "description": "Indicator of whether this authorization is currently active, or has been revoked", + "enum": [ + "PENDING", + "ACTIVE", + "DENIED", + "EXPIRED", + "REVOKED" + ] + }, + "userId": { + "type": "number", + "description": "Twitter's numeric ID for this user" + }, + "screenName": { + "type": "string", + "description": "The twitter username for this account (can be changed by the user)" + }, + "oauthToken": { + "type": "string", + "description": "The OAuth token for this Twitter account" + }, + "oauthTokenSecret": { + "type": "string", + "description": "The OAuth secret, used for signing requests on behalf of this Twitter account. `null` whilst the OAuth flow is not yet complete." + }, + "dateAuthorized": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) when the user last authorized this Twitter account" + } + } + } + }, + "toDoItems": { + "type": "array", + "items": { + "type": "object", + "description": "A record is one node in a To-Do item tree (every record can contain nested sub-records).", + "properties": { + "status": { + "type": "string", + "description": "User-selected state for this item (e.g. whether or not it is marked as done)", + "enum": [ + "HIDDEN", + "ACTIONABLE", + "DONE", + "ARCHIVED", + "DELETED" + ] + }, + "title": { + "type": "string", + "description": "One-line summary of the item" + }, + "description": { + "type": "string", + "description": "Detailed description (may contain HTML markup)" + }, + "snoozeDate": { + "type": "number", + "description": "Timestamp (milliseconds since epoch) at which the item should go from `HIDDEN` to `ACTIONABLE` status" + }, + "subItems": { + "type": "array", + "doc": "List of children of this to-do tree node", + "items": { + "$ref": "#/components/messages/UserSignedUp/payload/schema/properties/toDoItems" + } + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/test/docs/3.0.0/streetlights-openapi.json b/test/docs/3.0.0/streetlights-openapi.json index 08f25ae4..2d99bcb3 100644 --- a/test/docs/3.0.0/streetlights-openapi.json +++ b/test/docs/3.0.0/streetlights-openapi.json @@ -6,20 +6,20 @@ "description": "This service is in charge of processing user signups" }, "channels": { - "UserSignedUpChannel": { + "OpenAPI-UserSignedUpChannel": { "address": "user/signedup", "messages": { "UserSignedUp": { - "$ref": "#/components/messages/UserSignedUp" + "$ref": "#/components/messages/OpenAPI-UserSignedUp" } } } }, "operations": { - "PublishUserSignedUp": { + "OpenAPI-PublishUserSignedUp": { "action": "send", "channel": { - "$ref": "#/channels/UserSignedUpChannel" + "$ref": "#/channels/OpenAPI-UserSignedUpChannel" }, "bindings": { "mqtt": { @@ -37,10 +37,10 @@ } } }, - "PublishUserSignedUpDefaultBinding": { + "OpenAPI-PublishUserSignedUpDefaultBinding": { "action": "send", "channel": { - "$ref": "#/channels/UserSignedUpChannel" + "$ref": "#/channels/OpenAPI-UserSignedUpChannel" }, "bindings": { "mqtt": { @@ -59,7 +59,7 @@ }, "components": { "schemas": { - "ReferencedSchema" : { + "OpenAPI-ReferencedSchema" : { "schemaFormat": "application/vnd.oai.openapi;version=3.0.0", "schema": { "$ref": "reference-to-some-openapi-file.json" @@ -67,7 +67,7 @@ } }, "messages": { - "UserSignedUp": { + "OpenAPI-UserSignedUp": { "payload": { "schemaFormat": "application/vnd.oai.openapi;version=3.0.0", "schema": { diff --git a/test/docs/3.0.0/streetlights-unknown.json b/test/docs/3.0.0/streetlights-unknown.json new file mode 100644 index 00000000..cca2c654 --- /dev/null +++ b/test/docs/3.0.0/streetlights-unknown.json @@ -0,0 +1,106 @@ +{ + "asyncapi": "3.0.0", + "info": { + "title": "Account Service", + "version": "1.0.0", + "description": "This service is in charge of processing user signups" + }, + "channels": { + "Unknown-UserSignedUpChannel": { + "address": "user/signedup/{test_param}", + "parameters": { + "test_param": { + "enum": [ + "test" + ], + "default": "test", + "description": "Just a test description", + "examples": [ + "test" + ], + "location": "$message.payload#", + "x-custom-extension": "test" + } + }, + "messages": { + "UserSignedUp": { + "$ref": "#/components/messages/Unknown-UserSignedUp" + } + } + } + }, + "operations": { + "Unknown-PublishUserSignedUp": { + "action": "send", + "channel": { + "$ref": "#/channels/Unknown-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "bindingVersion": "0.2.0", + "qos": 1 + }, + "kafka": { + "bindingVersion": "0.3.0", + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + }, + "Unknown-PublishUserSignedUpDefaultBinding": { + "action": "send", + "channel": { + "$ref": "#/channels/Unknown-UserSignedUpChannel" + }, + "bindings": { + "mqtt": { + "qos": 1 + }, + "kafka": { + "clientId": { + "type": "string", + "enum": [ + "my-app-id" + ] + } + } + } + } + }, + "components": { + "messages": { + "Unknown-UserSignedUp": { + "payload": { + "schemaFormat": "unknown-schema-format", + "schema": { + "type": "object", + "properties": { + "displayName": { + "type": "string", + "description": "Name of the user" + }, + "email": { + "type": "string", + "format": "email", + "description": "Email of the user" + } + }, + "externalDocs": { + "url": "https://account-service/docs/UserSignedUp" + }, + "deprecated": false + } + } + }, + "Unknown-UserSignedUpV2": { + "payload": { + "$ref": "external-schema.json" + } + } + } + } +} \ No newline at end of file diff --git a/tools/bundler/index.js b/tools/bundler/index.js index c405b2e4..3596c8b3 100644 --- a/tools/bundler/index.js +++ b/tools/bundler/index.js @@ -165,7 +165,23 @@ function getDefinitionName(def) { } if (def.startsWith('http://asyncapi.com/bindings')) { const result = bindingsRegex.exec(def); - if (result) return `${result[1].replace('/', '-')}-${result[2]}-${result[3]}`; + if (result) { + /* + 4th element is for internal definitions like http://asyncapi.com/bindings/jms/0.0.1/server.json#/definitions/property + + When is empty, we can ignore it: + convert this: http://asyncapi.com/bindings/jms/0.0.1/server.json + to this: bindings-jms-0.0.1-server + Otherwise we MUST add it to not broke Json Schema validation: + convert this: http://asyncapi.com/bindings/jms/0.0.1/server.json#/definitions/property + to this: bindings-jms-0.0.1-server/definitions/property + */ + if (result[4] === '') { + return `${result[1].replace('/', '-')}-${result[2]}-${result[3]}`; + } + + return `${result[1].replace('/', '-')}-${result[2]}-${result[3]}/${result[4].replace('#/', '')}`; + } } return path.basename(def, '.json');