Skip to content

Commit

Permalink
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Browse files Browse the repository at this point in the history
…erencing a json schema

New multiFormatSchema validation rules

#494
asyncapi/jasyncapi-idea-plugin#49
  • Loading branch information
Pakisan committed Mar 25, 2024
1 parent dddb3d3 commit a4c5ef0
Show file tree
Hide file tree
Showing 12 changed files with 1,881 additions and 292 deletions.
21 changes: 14 additions & 7 deletions common/avroSchema_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
},
"required": [
"type"
]
],
"additionalProperties": false
},
"customTypeReference": {
"title": "Custom Type",
Expand Down Expand Up @@ -122,7 +123,8 @@
"required": [
"name",
"type"
]
],
"additionalProperties": false
},
"avroRecord": {
"title": "Record",
Expand Down Expand Up @@ -159,7 +161,8 @@
"type",
"name",
"fields"
]
],
"additionalProperties": false
},
"avroEnum": {
"title": "Enum",
Expand Down Expand Up @@ -196,7 +199,8 @@
"type",
"name",
"symbols"
]
],
"additionalProperties": false
},
"avroArray": {
"title": "Array",
Expand Down Expand Up @@ -229,7 +233,8 @@
"required": [
"type",
"items"
]
],
"additionalProperties": false
},
"avroMap": {
"title": "Map",
Expand Down Expand Up @@ -262,7 +267,8 @@
"required": [
"type",
"values"
]
],
"additionalProperties": false
},
"avroFixed": {
"title": "Fixed",
Expand Down Expand Up @@ -296,7 +302,8 @@
"type",
"name",
"size"
]
],
"additionalProperties": false
},
"name": {
"type": "string",
Expand Down
152 changes: 35 additions & 117 deletions definitions/3.0.0/anySchema.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
9 changes: 1 addition & 8 deletions definitions/3.0.0/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
},
Expand Down
Loading

0 comments on commit a4c5ef0

Please sign in to comment.