From a4c5ef0776b5c34d2f3f6e76edbb146367d802f2 Mon Sep 17 00:00:00 2001 From: Pavel Bodiachevskii Date: Mon, 25 Mar 2024 18:11:09 +0400 Subject: [PATCH] fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when referencing a json schema New multiFormatSchema validation rules https://github.com/asyncapi/spec-json-schemas/issues/494 https://github.com/asyncapi/jasyncapi-idea-plugin/issues/49 --- common/avroSchema_v1.json | 21 +- definitions/3.0.0/anySchema.json | 152 ++--- definitions/3.0.0/components.json | 9 +- definitions/3.0.0/multiFormatSchema.json | 236 +++++++ schemas/3.0.0-without-$id.json | 287 +++++++-- schemas/3.0.0.json | 288 +++++++-- test/docs/3.0.0/streetlights-all.json | 687 ++++++++++++++++++++- test/docs/3.0.0/streetlights-asyncapi.json | 126 ++++ test/docs/3.0.0/streetlights-avro.json | 20 +- test/docs/3.0.0/streetlights-json.json | 225 +++++++ test/docs/3.0.0/streetlights-openapi.json | 16 +- test/docs/3.0.0/streetlights-unknown.json | 106 ++++ 12 files changed, 1881 insertions(+), 292 deletions(-) create mode 100644 definitions/3.0.0/multiFormatSchema.json create mode 100644 test/docs/3.0.0/streetlights-asyncapi.json create mode 100644 test/docs/3.0.0/streetlights-json.json create mode 100644 test/docs/3.0.0/streetlights-unknown.json diff --git a/common/avroSchema_v1.json b/common/avroSchema_v1.json index d3448f10..72bc4dae 100644 --- a/common/avroSchema_v1.json +++ b/common/avroSchema_v1.json @@ -70,7 +70,8 @@ }, "required": [ "type" - ] + ], + "additionalProperties": false }, "customTypeReference": { "title": "Custom Type", @@ -122,7 +123,8 @@ "required": [ "name", "type" - ] + ], + "additionalProperties": false }, "avroRecord": { "title": "Record", @@ -159,7 +161,8 @@ "type", "name", "fields" - ] + ], + "additionalProperties": false }, "avroEnum": { "title": "Enum", @@ -196,7 +199,8 @@ "type", "name", "symbols" - ] + ], + "additionalProperties": false }, "avroArray": { "title": "Array", @@ -229,7 +233,8 @@ "required": [ "type", "items" - ] + ], + "additionalProperties": false }, "avroMap": { "title": "Map", @@ -262,7 +267,8 @@ "required": [ "type", "values" - ] + ], + "additionalProperties": false }, "avroFixed": { "title": "Fixed", @@ -296,7 +302,8 @@ "type", "name", "size" - ] + ], + "additionalProperties": false }, "name": { "type": "string", diff --git a/definitions/3.0.0/anySchema.json b/definitions/3.0.0/anySchema.json index 0a7d387d..cc60af06 100644 --- a/definitions/3.0.0/anySchema.json +++ b/definitions/3.0.0/anySchema.json @@ -1,132 +1,50 @@ { - "description": "An object representing either a schema or a multiFormatSchema based on the existence of the 'schema' property. If the property 'schema' is present, use the multi-format schema. Use the default AsyncAPI Schema otherwise.", + "$id": "http://asyncapi.com/definitions/3.0.0/anySchema.json", + "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", - "anyOf": [ - { - "type": "object", - "description": "AsyncAPI Schema", - "not": { - "required": ["schemaFormat", "schema"] - }, - "additionalProperties": false, - "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" - }, - { - "type": "object", - "description": "Multi format schema: Avro Schema", - "required": ["schemaFormat", "schema"], - "not": {"required": ["$ref"]}, - "additionalProperties": false, - "properties": { - "schemaFormat": { - "type": "string", - "enum": [ - "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" - ] - }, - "schema": { - "if": { - "not": {"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"} - }, - "then": { - "$ref": "http://asyncapi.com/definitions/3.0.0/avroSchema_v1.json" - }, - "else": { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - } - } - } + "description": "An object representing either a Reference, a Schema or a Multi Format Schema", + "properties": { + "schemaFormat": { + "type": "string", + "description": "Supported Schema format" }, - { + "schema": { "type": "object", - "description": "Multi format schema: OpenAPI Schema", - "required": ["schemaFormat", "schema"], - "not": {"required": ["$ref"]}, - "additionalProperties": false, - "properties": { - "schemaFormat": { - "type": "string", - "enum": [ - "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" - ] - }, - "schema": { - "anyOf": [ - { - "$ref": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json" - }, - { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - } - ] - } - } + "description": "Schema definition" }, + "$ref": { + "type": "string", + "description": "Reference to schema" + } + }, + "minProperties": 1, + "oneOf": [ { - "type": "object", - "description": "Multi format schema: Json Schema", - "required": ["schemaFormat", "schema"], - "not": {"required": ["$ref"]}, - "additionalProperties": false, - "properties": { - "schemaFormat": { - "type": "string", - "enum": [ - "application/schema+json;version=draft-07", - "application/schema+yaml;version=draft-07" - ] + "description": "Because of $ref collision in Reference and AsyncAPI Schema(includes $ref from Json Schema)", + "not": {"required": ["schemaFormat", "schema"]}, + "anyOf": [ + { + "type": "object", + "required": ["$ref"], + "not": {"required": ["schemaFormat", "schema"]}, + "minProperties": 1, + "maxProperties": 1, + "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" }, - "schema": { - "$ref": "http://json-schema.org/draft-07/schema" + { + "type": "object", + "not": {"required": ["schemaFormat", "schema"]}, + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" } - } + ] }, { "type": "object", - "description": "Multi format schema: AsyncAPI Schema", "required": ["schemaFormat", "schema"], "not": {"required": ["$ref"]}, - "additionalProperties": false, - "properties": { - "schemaFormat": { - "type": "string", - "enum": [ - "application/vnd.aai.asyncapi;version=2.0.0", - "application/vnd.aai.asyncapi+json;version=2.0.0", - "application/vnd.aai.asyncapi+yaml;version=2.0.0", - "application/vnd.aai.asyncapi;version=2.1.0", - "application/vnd.aai.asyncapi+json;version=2.1.0", - "application/vnd.aai.asyncapi+yaml;version=2.1.0", - "application/vnd.aai.asyncapi;version=2.2.0", - "application/vnd.aai.asyncapi+json;version=2.2.0", - "application/vnd.aai.asyncapi+yaml;version=2.2.0", - "application/vnd.aai.asyncapi;version=2.3.0", - "application/vnd.aai.asyncapi+json;version=2.3.0", - "application/vnd.aai.asyncapi+yaml;version=2.3.0", - "application/vnd.aai.asyncapi;version=2.4.0", - "application/vnd.aai.asyncapi+json;version=2.4.0", - "application/vnd.aai.asyncapi+yaml;version=2.4.0", - "application/vnd.aai.asyncapi;version=2.5.0", - "application/vnd.aai.asyncapi+json;version=2.5.0", - "application/vnd.aai.asyncapi+yaml;version=2.5.0", - "application/vnd.aai.asyncapi;version=2.6.0", - "application/vnd.aai.asyncapi+json;version=2.6.0", - "application/vnd.aai.asyncapi+yaml;version=2.6.0", - "application/vnd.aai.asyncapi;version=3.0.0", - "application/vnd.aai.asyncapi+json;version=3.0.0", - "application/vnd.aai.asyncapi+yaml;version=3.0.0" - ] - }, - "schema": { - "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" - } - } + "minProperties": 2, + "maxProperties": 2, + "$ref": "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json" } - ], - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "http://asyncapi.com/definitions/3.0.0/anySchema.json" + ] } 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 new file mode 100644 index 00000000..dd03f474 --- /dev/null +++ b/definitions/3.0.0/multiFormatSchema.json @@ -0,0 +1,236 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json", + "description": "An object representing Multi Format Schema. You can use it to attach Schemas different to AsyncAPI, like Avro or OpenAPI", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" + } + }, + "required": ["schemaFormat", "schema"], + "properties": { + "schemaFormat": { + "type": "string", + "description": "Supported Schema formats" + }, + "schema": { + "type": "object", + "description": "Schema definition" + } + }, + "minProperties": 2, + "maxProperties": 2, + "oneOf": [ + { + "type": "object", + "description": "Multi Format Schema: Avro Schema or Reference", + "properties": { + "schemaFormat": { + "type": "string", + "enum": [ + "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" + ] + }, + "schema": { + "oneOf": [ + { + "type": "object", + "description": "Avro Schema", + "not": {"required": ["$ref"]}, + "$ref": "http://asyncapi.com/definitions/3.0.0/avroSchema_v1.json" + }, + { + "type": "object", + "description": "Reference to Avro Schema", + "required": ["$ref"], + "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" + } + ] + } + } + }, + { + "type": "object", + "description": "Multi Format Schema: OpenAPI Schema or Reference", + "properties": { + "schemaFormat": { + "type": "string", + "enum": [ + "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" + ] + }, + "schema": { + "oneOf": [ + { + "type": "object", + "description": "OpenAPI Schema", + "not": {"required": ["$ref"]}, + "$ref": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json" + }, + { + "type": "object", + "description": "Reference to OpenAPI Schema", + "required": ["$ref"], + "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" + } + ] + } + } + }, + { + "type": "object", + "description": "Multi Format Schema: Json Schema or Reference", + "properties": { + "schemaFormat": { + "type": "string", + "enum": [ + "application/schema+json;version=draft-07", + "application/schema+yaml;version=draft-07" + ] + }, + "schema": { + "description": "Because of $ref collision in Reference and Json Schema", + "anyOf": [ + { + "type": "object", + "description": "Json Schema", + "not": {"required": ["$ref"]}, + "$ref": "http://json-schema.org/draft-07/schema" + }, + { + "type": "object", + "description": "Reference to Json Schema", + "required": ["$ref"], + "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" + } + ] + } + } + }, + { + "type": "object", + "description": "Multi Format Schema: AsyncAPI Schema or Reference", + "properties": { + "schemaFormat": { + "type": "string", + "enum": [ + "application/vnd.aai.asyncapi;version=2.0.0", + "application/vnd.aai.asyncapi+json;version=2.0.0", + "application/vnd.aai.asyncapi+yaml;version=2.0.0", + + "application/vnd.aai.asyncapi;version=2.1.0", + "application/vnd.aai.asyncapi+json;version=2.1.0", + "application/vnd.aai.asyncapi+yaml;version=2.1.0", + + "application/vnd.aai.asyncapi;version=2.2.0", + "application/vnd.aai.asyncapi+json;version=2.2.0", + "application/vnd.aai.asyncapi+yaml;version=2.2.0", + + "application/vnd.aai.asyncapi;version=2.3.0", + "application/vnd.aai.asyncapi+json;version=2.3.0", + "application/vnd.aai.asyncapi+yaml;version=2.3.0", + + "application/vnd.aai.asyncapi;version=2.4.0", + "application/vnd.aai.asyncapi+json;version=2.4.0", + "application/vnd.aai.asyncapi+yaml;version=2.4.0", + + "application/vnd.aai.asyncapi;version=2.5.0", + "application/vnd.aai.asyncapi+json;version=2.5.0", + "application/vnd.aai.asyncapi+yaml;version=2.5.0", + + "application/vnd.aai.asyncapi;version=2.6.0", + "application/vnd.aai.asyncapi+json;version=2.6.0", + "application/vnd.aai.asyncapi+yaml;version=2.6.0", + + "application/vnd.aai.asyncapi;version=3.0.0", + "application/vnd.aai.asyncapi+json;version=3.0.0", + "application/vnd.aai.asyncapi+yaml;version=3.0.0" + ] + }, + "schema": { + "description": "Because of $ref collision in Reference and AsyncAPI Schema", + "anyOf": [ + { + "type": "object", + "description": "AsyncAPI Schema", + "not": {"required": ["$ref"]}, + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" + }, + { + "type": "object", + "description": "Reference to AsyncAPI Schema", + "required": ["$ref"], + "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" + } + ] + } + } + }, + { + "type": "object", + "description": "Multi Format Schema: Unknown Schema is AsyncAPI Schema", + "properties": { + "schemaFormat": { + "type": "string", + "not": { + "enum": [ + "application/vnd.aai.asyncapi;version=2.0.0", + "application/vnd.aai.asyncapi+json;version=2.0.0", + "application/vnd.aai.asyncapi+yaml;version=2.0.0", + + "application/vnd.aai.asyncapi;version=2.1.0", + "application/vnd.aai.asyncapi+json;version=2.1.0", + "application/vnd.aai.asyncapi+yaml;version=2.1.0", + + "application/vnd.aai.asyncapi;version=2.2.0", + "application/vnd.aai.asyncapi+json;version=2.2.0", + "application/vnd.aai.asyncapi+yaml;version=2.2.0", + + "application/vnd.aai.asyncapi;version=2.3.0", + "application/vnd.aai.asyncapi+json;version=2.3.0", + "application/vnd.aai.asyncapi+yaml;version=2.3.0", + + "application/vnd.aai.asyncapi;version=2.4.0", + "application/vnd.aai.asyncapi+json;version=2.4.0", + "application/vnd.aai.asyncapi+yaml;version=2.4.0", + + "application/vnd.aai.asyncapi;version=2.5.0", + "application/vnd.aai.asyncapi+json;version=2.5.0", + "application/vnd.aai.asyncapi+yaml;version=2.5.0", + + "application/vnd.aai.asyncapi;version=2.6.0", + "application/vnd.aai.asyncapi+json;version=2.6.0", + "application/vnd.aai.asyncapi+yaml;version=2.6.0", + + "application/vnd.aai.asyncapi;version=3.0.0", + "application/vnd.aai.asyncapi+json;version=3.0.0", + "application/vnd.aai.asyncapi+yaml;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/schema+json;version=draft-07", + "application/schema+yaml;version=draft-07" + ] + } + }, + "schema": { + "type": "object", + "description": "AsyncAPI Schema", + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" + } + } + } + ] +} \ No newline at end of file diff --git a/schemas/3.0.0-without-$id.json b/schemas/3.0.0-without-$id.json index e9934f15..574c75ed 100644 --- a/schemas/3.0.0-without-$id.json +++ b/schemas/3.0.0-without-$id.json @@ -2686,24 +2686,62 @@ ] }, "anySchema": { - "description": "An object representing either a schema or a multiFormatSchema based on the existence of the 'schema' property. If the property 'schema' is present, use the multi-format schema. Use the default AsyncAPI Schema otherwise.", "type": "object", - "anyOf": [ - { + "description": "An object representing either a Reference, a Schema or a Multi Format Schema", + "properties": { + "schemaFormat": { + "type": "string", + "description": "Supported Schema format" + }, + "schema": { "type": "object", - "description": "AsyncAPI Schema", + "description": "Schema definition" + }, + "$ref": { + "type": "string", + "description": "Reference to schema" + } + }, + "minProperties": 1, + "oneOf": [ + { + "description": "Because of $ref collision in Reference and AsyncAPI Schema(includes $ref from Json Schema)", "not": { "required": [ "schemaFormat", "schema" ] }, - "additionalProperties": false, - "$ref": "#/definitions/schema" + "anyOf": [ + { + "type": "object", + "required": [ + "$ref" + ], + "not": { + "required": [ + "schemaFormat", + "schema" + ] + }, + "minProperties": 1, + "maxProperties": 1, + "$ref": "#/definitions/Reference" + }, + { + "type": "object", + "not": { + "required": [ + "schemaFormat", + "schema" + ] + }, + "$ref": "#/definitions/schema" + } + ] }, { "type": "object", - "description": "Multi format schema: Avro Schema", "required": [ "schemaFormat", "schema" @@ -2713,7 +2751,41 @@ "$ref" ] }, - "additionalProperties": false, + "minProperties": 2, + "maxProperties": 2, + "$ref": "#/definitions/multiFormatSchema" + } + ] + }, + "multiFormatSchema": { + "description": "An object representing Multi Format Schema. You can use it to attach Schemas different to AsyncAPI, like Avro or OpenAPI", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "#/definitions/specificationExtension" + } + }, + "required": [ + "schemaFormat", + "schema" + ], + "properties": { + "schemaFormat": { + "type": "string", + "description": "Supported Schema formats" + }, + "schema": { + "type": "object", + "description": "Schema definition" + } + }, + "minProperties": 2, + "maxProperties": 2, + "oneOf": [ + { + "type": "object", + "description": "Multi Format Schema: Avro Schema or Reference", "properties": { "schemaFormat": { "type": "string", @@ -2724,33 +2796,32 @@ ] }, "schema": { - "if": { - "not": { + "oneOf": [ + { + "type": "object", + "description": "Avro Schema", + "not": { + "required": [ + "$ref" + ] + }, + "$ref": "#/definitions/avroSchema_v1" + }, + { + "type": "object", + "description": "Reference to Avro Schema", + "required": [ + "$ref" + ], "$ref": "#/definitions/Reference" } - }, - "then": { - "$ref": "#/definitions/avroSchema_v1" - }, - "else": { - "$ref": "#/definitions/Reference" - } + ] } } }, { "type": "object", - "description": "Multi format schema: OpenAPI Schema", - "required": [ - "schemaFormat", - "schema" - ], - "not": { - "required": [ - "$ref" - ] - }, - "additionalProperties": false, + "description": "Multi Format Schema: OpenAPI Schema or Reference", "properties": { "schemaFormat": { "type": "string", @@ -2761,11 +2832,23 @@ ] }, "schema": { - "anyOf": [ + "oneOf": [ { + "type": "object", + "description": "OpenAPI Schema", + "not": { + "required": [ + "$ref" + ] + }, "$ref": "#/definitions/openapiSchema_3_0" }, { + "type": "object", + "description": "Reference to OpenAPI Schema", + "required": [ + "$ref" + ], "$ref": "#/definitions/Reference" } ] @@ -2774,17 +2857,7 @@ }, { "type": "object", - "description": "Multi format schema: Json Schema", - "required": [ - "schemaFormat", - "schema" - ], - "not": { - "required": [ - "$ref" - ] - }, - "additionalProperties": false, + "description": "Multi Format Schema: Json Schema or Reference", "properties": { "schemaFormat": { "type": "string", @@ -2794,23 +2867,33 @@ ] }, "schema": { - "$ref": "#/definitions/json-schema-draft-07-schema" + "description": "Because of $ref collision in Reference and Json Schema", + "anyOf": [ + { + "type": "object", + "description": "Json Schema", + "not": { + "required": [ + "$ref" + ] + }, + "$ref": "#/definitions/json-schema-draft-07-schema" + }, + { + "type": "object", + "description": "Reference to Json Schema", + "required": [ + "$ref" + ], + "$ref": "#/definitions/Reference" + } + ] } } }, { "type": "object", - "description": "Multi format schema: AsyncAPI Schema", - "required": [ - "schemaFormat", - "schema" - ], - "not": { - "required": [ - "$ref" - ] - }, - "additionalProperties": false, + "description": "Multi Format Schema: AsyncAPI Schema or Reference", "properties": { "schemaFormat": { "type": "string", @@ -2842,6 +2925,76 @@ ] }, "schema": { + "description": "Because of $ref collision in Reference and AsyncAPI Schema", + "anyOf": [ + { + "type": "object", + "description": "AsyncAPI Schema", + "not": { + "required": [ + "$ref" + ] + }, + "$ref": "#/definitions/schema" + }, + { + "type": "object", + "description": "Reference to AsyncAPI Schema", + "required": [ + "$ref" + ], + "$ref": "#/definitions/Reference" + } + ] + } + } + }, + { + "type": "object", + "description": "Multi Format Schema: Unknown Schema is AsyncAPI Schema", + "properties": { + "schemaFormat": { + "type": "string", + "not": { + "enum": [ + "application/vnd.aai.asyncapi;version=2.0.0", + "application/vnd.aai.asyncapi+json;version=2.0.0", + "application/vnd.aai.asyncapi+yaml;version=2.0.0", + "application/vnd.aai.asyncapi;version=2.1.0", + "application/vnd.aai.asyncapi+json;version=2.1.0", + "application/vnd.aai.asyncapi+yaml;version=2.1.0", + "application/vnd.aai.asyncapi;version=2.2.0", + "application/vnd.aai.asyncapi+json;version=2.2.0", + "application/vnd.aai.asyncapi+yaml;version=2.2.0", + "application/vnd.aai.asyncapi;version=2.3.0", + "application/vnd.aai.asyncapi+json;version=2.3.0", + "application/vnd.aai.asyncapi+yaml;version=2.3.0", + "application/vnd.aai.asyncapi;version=2.4.0", + "application/vnd.aai.asyncapi+json;version=2.4.0", + "application/vnd.aai.asyncapi+yaml;version=2.4.0", + "application/vnd.aai.asyncapi;version=2.5.0", + "application/vnd.aai.asyncapi+json;version=2.5.0", + "application/vnd.aai.asyncapi+yaml;version=2.5.0", + "application/vnd.aai.asyncapi;version=2.6.0", + "application/vnd.aai.asyncapi+json;version=2.6.0", + "application/vnd.aai.asyncapi+yaml;version=2.6.0", + "application/vnd.aai.asyncapi;version=3.0.0", + "application/vnd.aai.asyncapi+json;version=3.0.0", + "application/vnd.aai.asyncapi+yaml;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/schema+json;version=draft-07", + "application/schema+yaml;version=draft-07" + ] + } + }, + "schema": { + "type": "object", + "description": "AsyncAPI Schema", "$ref": "#/definitions/schema" } } @@ -2918,7 +3071,8 @@ }, "required": [ "type" - ] + ], + "additionalProperties": false }, "customTypeReference": { "title": "Custom Type", @@ -2970,7 +3124,8 @@ "required": [ "name", "type" - ] + ], + "additionalProperties": false }, "avroRecord": { "title": "Record", @@ -3007,7 +3162,8 @@ "type", "name", "fields" - ] + ], + "additionalProperties": false }, "avroEnum": { "title": "Enum", @@ -3044,7 +3200,8 @@ "type", "name", "symbols" - ] + ], + "additionalProperties": false }, "avroArray": { "title": "Array", @@ -3077,7 +3234,8 @@ "required": [ "type", "items" - ] + ], + "additionalProperties": false }, "avroMap": { "title": "Map", @@ -3110,7 +3268,8 @@ "required": [ "type", "values" - ] + ], + "additionalProperties": false }, "avroFixed": { "title": "Fixed", @@ -3144,7 +3303,8 @@ "type", "name", "size" - ] + ], + "additionalProperties": false }, "name": { "type": "string", @@ -8441,14 +8601,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 7a0de46b..f6da964a 100644 --- a/schemas/3.0.0.json +++ b/schemas/3.0.0.json @@ -2736,24 +2736,62 @@ }, "http://asyncapi.com/definitions/3.0.0/anySchema.json": { "$id": "http://asyncapi.com/definitions/3.0.0/anySchema.json", - "description": "An object representing either a schema or a multiFormatSchema based on the existence of the 'schema' property. If the property 'schema' is present, use the multi-format schema. Use the default AsyncAPI Schema otherwise.", "type": "object", - "anyOf": [ - { + "description": "An object representing either a Reference, a Schema or a Multi Format Schema", + "properties": { + "schemaFormat": { + "type": "string", + "description": "Supported Schema format" + }, + "schema": { "type": "object", - "description": "AsyncAPI Schema", + "description": "Schema definition" + }, + "$ref": { + "type": "string", + "description": "Reference to schema" + } + }, + "minProperties": 1, + "oneOf": [ + { + "description": "Because of $ref collision in Reference and AsyncAPI Schema(includes $ref from Json Schema)", "not": { "required": [ "schemaFormat", "schema" ] }, - "additionalProperties": false, - "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" + "anyOf": [ + { + "type": "object", + "required": [ + "$ref" + ], + "not": { + "required": [ + "schemaFormat", + "schema" + ] + }, + "minProperties": 1, + "maxProperties": 1, + "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" + }, + { + "type": "object", + "not": { + "required": [ + "schemaFormat", + "schema" + ] + }, + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" + } + ] }, { "type": "object", - "description": "Multi format schema: Avro Schema", "required": [ "schemaFormat", "schema" @@ -2763,7 +2801,42 @@ "$ref" ] }, - "additionalProperties": false, + "minProperties": 2, + "maxProperties": 2, + "$ref": "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json" + } + ] + }, + "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json": { + "$id": "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json", + "description": "An object representing Multi Format Schema. You can use it to attach Schemas different to AsyncAPI, like Avro or OpenAPI", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" + } + }, + "required": [ + "schemaFormat", + "schema" + ], + "properties": { + "schemaFormat": { + "type": "string", + "description": "Supported Schema formats" + }, + "schema": { + "type": "object", + "description": "Schema definition" + } + }, + "minProperties": 2, + "maxProperties": 2, + "oneOf": [ + { + "type": "object", + "description": "Multi Format Schema: Avro Schema or Reference", "properties": { "schemaFormat": { "type": "string", @@ -2774,33 +2847,32 @@ ] }, "schema": { - "if": { - "not": { + "oneOf": [ + { + "type": "object", + "description": "Avro Schema", + "not": { + "required": [ + "$ref" + ] + }, + "$ref": "http://asyncapi.com/definitions/3.0.0/avroSchema_v1.json" + }, + { + "type": "object", + "description": "Reference to Avro Schema", + "required": [ + "$ref" + ], "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" } - }, - "then": { - "$ref": "http://asyncapi.com/definitions/3.0.0/avroSchema_v1.json" - }, - "else": { - "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" - } + ] } } }, { "type": "object", - "description": "Multi format schema: OpenAPI Schema", - "required": [ - "schemaFormat", - "schema" - ], - "not": { - "required": [ - "$ref" - ] - }, - "additionalProperties": false, + "description": "Multi Format Schema: OpenAPI Schema or Reference", "properties": { "schemaFormat": { "type": "string", @@ -2811,11 +2883,23 @@ ] }, "schema": { - "anyOf": [ + "oneOf": [ { + "type": "object", + "description": "OpenAPI Schema", + "not": { + "required": [ + "$ref" + ] + }, "$ref": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json" }, { + "type": "object", + "description": "Reference to OpenAPI Schema", + "required": [ + "$ref" + ], "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" } ] @@ -2824,17 +2908,7 @@ }, { "type": "object", - "description": "Multi format schema: Json Schema", - "required": [ - "schemaFormat", - "schema" - ], - "not": { - "required": [ - "$ref" - ] - }, - "additionalProperties": false, + "description": "Multi Format Schema: Json Schema or Reference", "properties": { "schemaFormat": { "type": "string", @@ -2844,23 +2918,33 @@ ] }, "schema": { - "$ref": "http://json-schema.org/draft-07/schema" + "description": "Because of $ref collision in Reference and Json Schema", + "anyOf": [ + { + "type": "object", + "description": "Json Schema", + "not": { + "required": [ + "$ref" + ] + }, + "$ref": "http://json-schema.org/draft-07/schema" + }, + { + "type": "object", + "description": "Reference to Json Schema", + "required": [ + "$ref" + ], + "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" + } + ] } } }, { "type": "object", - "description": "Multi format schema: AsyncAPI Schema", - "required": [ - "schemaFormat", - "schema" - ], - "not": { - "required": [ - "$ref" - ] - }, - "additionalProperties": false, + "description": "Multi Format Schema: AsyncAPI Schema or Reference", "properties": { "schemaFormat": { "type": "string", @@ -2892,6 +2976,76 @@ ] }, "schema": { + "description": "Because of $ref collision in Reference and AsyncAPI Schema", + "anyOf": [ + { + "type": "object", + "description": "AsyncAPI Schema", + "not": { + "required": [ + "$ref" + ] + }, + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" + }, + { + "type": "object", + "description": "Reference to AsyncAPI Schema", + "required": [ + "$ref" + ], + "$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json" + } + ] + } + } + }, + { + "type": "object", + "description": "Multi Format Schema: Unknown Schema is AsyncAPI Schema", + "properties": { + "schemaFormat": { + "type": "string", + "not": { + "enum": [ + "application/vnd.aai.asyncapi;version=2.0.0", + "application/vnd.aai.asyncapi+json;version=2.0.0", + "application/vnd.aai.asyncapi+yaml;version=2.0.0", + "application/vnd.aai.asyncapi;version=2.1.0", + "application/vnd.aai.asyncapi+json;version=2.1.0", + "application/vnd.aai.asyncapi+yaml;version=2.1.0", + "application/vnd.aai.asyncapi;version=2.2.0", + "application/vnd.aai.asyncapi+json;version=2.2.0", + "application/vnd.aai.asyncapi+yaml;version=2.2.0", + "application/vnd.aai.asyncapi;version=2.3.0", + "application/vnd.aai.asyncapi+json;version=2.3.0", + "application/vnd.aai.asyncapi+yaml;version=2.3.0", + "application/vnd.aai.asyncapi;version=2.4.0", + "application/vnd.aai.asyncapi+json;version=2.4.0", + "application/vnd.aai.asyncapi+yaml;version=2.4.0", + "application/vnd.aai.asyncapi;version=2.5.0", + "application/vnd.aai.asyncapi+json;version=2.5.0", + "application/vnd.aai.asyncapi+yaml;version=2.5.0", + "application/vnd.aai.asyncapi;version=2.6.0", + "application/vnd.aai.asyncapi+json;version=2.6.0", + "application/vnd.aai.asyncapi+yaml;version=2.6.0", + "application/vnd.aai.asyncapi;version=3.0.0", + "application/vnd.aai.asyncapi+json;version=3.0.0", + "application/vnd.aai.asyncapi+yaml;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/schema+json;version=draft-07", + "application/schema+yaml;version=draft-07" + ] + } + }, + "schema": { + "type": "object", + "description": "AsyncAPI Schema", "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" } } @@ -2969,7 +3123,8 @@ }, "required": [ "type" - ] + ], + "additionalProperties": false }, "customTypeReference": { "title": "Custom Type", @@ -3021,7 +3176,8 @@ "required": [ "name", "type" - ] + ], + "additionalProperties": false }, "avroRecord": { "title": "Record", @@ -3058,7 +3214,8 @@ "type", "name", "fields" - ] + ], + "additionalProperties": false }, "avroEnum": { "title": "Enum", @@ -3095,7 +3252,8 @@ "type", "name", "symbols" - ] + ], + "additionalProperties": false }, "avroArray": { "title": "Array", @@ -3128,7 +3286,8 @@ "required": [ "type", "items" - ] + ], + "additionalProperties": false }, "avroMap": { "title": "Map", @@ -3161,7 +3320,8 @@ "required": [ "type", "values" - ] + ], + "additionalProperties": false }, "avroFixed": { "title": "Fixed", @@ -3195,7 +3355,8 @@ "type", "name", "size" - ] + ], + "additionalProperties": false }, "name": { "type": "string", @@ -8542,14 +8703,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