From d34130d11549fde6b8c24d9557c1b7e588c7b426 Mon Sep 17 00:00:00 2001 From: Pavel Bodiachevskii Date: Tue, 2 Apr 2024 22:31:23 +0400 Subject: [PATCH] fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when referencing a json schema Rollback AnySchema and AvroSchema 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 | 31 ++++++------- schemas/3.0.0.json | 74 ++++++++------------------------ 3 files changed, 38 insertions(+), 88 deletions(-) diff --git a/common/avroSchema_v1.json b/common/avroSchema_v1.json index 72bc4dae..d3448f10 100644 --- a/common/avroSchema_v1.json +++ b/common/avroSchema_v1.json @@ -70,8 +70,7 @@ }, "required": [ "type" - ], - "additionalProperties": false + ] }, "customTypeReference": { "title": "Custom Type", @@ -123,8 +122,7 @@ "required": [ "name", "type" - ], - "additionalProperties": false + ] }, "avroRecord": { "title": "Record", @@ -161,8 +159,7 @@ "type", "name", "fields" - ], - "additionalProperties": false + ] }, "avroEnum": { "title": "Enum", @@ -199,8 +196,7 @@ "type", "name", "symbols" - ], - "additionalProperties": false + ] }, "avroArray": { "title": "Array", @@ -233,8 +229,7 @@ "required": [ "type", "items" - ], - "additionalProperties": false + ] }, "avroMap": { "title": "Map", @@ -267,8 +262,7 @@ "required": [ "type", "values" - ], - "additionalProperties": false + ] }, "avroFixed": { "title": "Fixed", @@ -302,8 +296,7 @@ "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 d9b5bc5b..4a0bf239 100644 --- a/definitions/3.0.0/anySchema.json +++ b/definitions/3.0.0/anySchema.json @@ -1,21 +1,16 @@ { - "$id": "http://asyncapi.com/definitions/3.0.0/anySchema.json", + "if": { + "required": [ + "schema" + ] + }, + "then": { + "$ref": "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json" + }, + "else": { + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.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.", "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "description": "An object representing either a Reference, a Schema or a Multi Format Schema", - "oneOf": [ - { - "description": "Because of $ref collision in Reference and AsyncAPI Schema(includes $ref from Json Schema)", - "not": {"required": ["schemaFormat", "schema"]}, - "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" - }, - { - "type": "object", - "required": ["schemaFormat", "schema"], - "not": {"required": ["$ref"]}, - "minProperties": 2, - "maxProperties": 2, - "$ref": "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json" - } - ] + "$id": "http://asyncapi.com/definitions/3.0.0/anySchema.json" } diff --git a/schemas/3.0.0.json b/schemas/3.0.0.json index 210b3427..17dc5d36 100644 --- a/schemas/3.0.0.json +++ b/schemas/3.0.0.json @@ -2736,49 +2736,18 @@ }, "http://asyncapi.com/definitions/3.0.0/anySchema.json": { "$id": "http://asyncapi.com/definitions/3.0.0/anySchema.json", - "type": "object", - "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": "Schema definition" - }, - "$ref": { - "type": "string", - "description": "Reference to schema" - } + "if": { + "required": [ + "schema" + ] }, - "oneOf": [ - { - "description": "Because of $ref collision in Reference and AsyncAPI Schema(includes $ref from Json Schema)", - "not": { - "required": [ - "schemaFormat", - "schema" - ] - }, - "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" - }, - { - "type": "object", - "required": [ - "schemaFormat", - "schema" - ], - "not": { - "required": [ - "$ref" - ] - }, - "minProperties": 2, - "maxProperties": 2, - "$ref": "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json" - } - ] + "then": { + "$ref": "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json" + }, + "else": { + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.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." }, "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json": { "$id": "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json", @@ -3336,8 +3305,7 @@ }, "required": [ "type" - ], - "additionalProperties": false + ] }, "customTypeReference": { "title": "Custom Type", @@ -3389,8 +3357,7 @@ "required": [ "name", "type" - ], - "additionalProperties": false + ] }, "avroRecord": { "title": "Record", @@ -3427,8 +3394,7 @@ "type", "name", "fields" - ], - "additionalProperties": false + ] }, "avroEnum": { "title": "Enum", @@ -3465,8 +3431,7 @@ "type", "name", "symbols" - ], - "additionalProperties": false + ] }, "avroArray": { "title": "Array", @@ -3499,8 +3464,7 @@ "required": [ "type", "items" - ], - "additionalProperties": false + ] }, "avroMap": { "title": "Map", @@ -3533,8 +3497,7 @@ "required": [ "type", "values" - ], - "additionalProperties": false + ] }, "avroFixed": { "title": "Fixed", @@ -3568,8 +3531,7 @@ "type", "name", "size" - ], - "additionalProperties": false + ] }, "name": { "type": "string",