Skip to content

Commit a4c5ef0

Browse files
committed
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when referencing a json schema
New multiFormatSchema validation rules #494 asyncapi/jasyncapi-idea-plugin#49
1 parent dddb3d3 commit a4c5ef0

12 files changed

+1881
-292
lines changed

common/avroSchema_v1.json

+14-7
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@
7070
},
7171
"required": [
7272
"type"
73-
]
73+
],
74+
"additionalProperties": false
7475
},
7576
"customTypeReference": {
7677
"title": "Custom Type",
@@ -122,7 +123,8 @@
122123
"required": [
123124
"name",
124125
"type"
125-
]
126+
],
127+
"additionalProperties": false
126128
},
127129
"avroRecord": {
128130
"title": "Record",
@@ -159,7 +161,8 @@
159161
"type",
160162
"name",
161163
"fields"
162-
]
164+
],
165+
"additionalProperties": false
163166
},
164167
"avroEnum": {
165168
"title": "Enum",
@@ -196,7 +199,8 @@
196199
"type",
197200
"name",
198201
"symbols"
199-
]
202+
],
203+
"additionalProperties": false
200204
},
201205
"avroArray": {
202206
"title": "Array",
@@ -229,7 +233,8 @@
229233
"required": [
230234
"type",
231235
"items"
232-
]
236+
],
237+
"additionalProperties": false
233238
},
234239
"avroMap": {
235240
"title": "Map",
@@ -262,7 +267,8 @@
262267
"required": [
263268
"type",
264269
"values"
265-
]
270+
],
271+
"additionalProperties": false
266272
},
267273
"avroFixed": {
268274
"title": "Fixed",
@@ -296,7 +302,8 @@
296302
"type",
297303
"name",
298304
"size"
299-
]
305+
],
306+
"additionalProperties": false
300307
},
301308
"name": {
302309
"type": "string",

definitions/3.0.0/anySchema.json

+35-117
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,50 @@
11
{
2-
"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.",
2+
"$id": "http://asyncapi.com/definitions/3.0.0/anySchema.json",
3+
"$schema": "http://json-schema.org/draft-07/schema#",
34
"type": "object",
4-
"anyOf": [
5-
{
6-
"type": "object",
7-
"description": "AsyncAPI Schema",
8-
"not": {
9-
"required": ["schemaFormat", "schema"]
10-
},
11-
"additionalProperties": false,
12-
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
13-
},
14-
{
15-
"type": "object",
16-
"description": "Multi format schema: Avro Schema",
17-
"required": ["schemaFormat", "schema"],
18-
"not": {"required": ["$ref"]},
19-
"additionalProperties": false,
20-
"properties": {
21-
"schemaFormat": {
22-
"type": "string",
23-
"enum": [
24-
"application/vnd.apache.avro;version=1.9.0",
25-
"application/vnd.apache.avro+json;version=1.9.0",
26-
"application/vnd.apache.avro+yaml;version=1.9.0"
27-
]
28-
},
29-
"schema": {
30-
"if": {
31-
"not": {"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"}
32-
},
33-
"then": {
34-
"$ref": "http://asyncapi.com/definitions/3.0.0/avroSchema_v1.json"
35-
},
36-
"else": {
37-
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
38-
}
39-
}
40-
}
5+
"description": "An object representing either a Reference, a Schema or a Multi Format Schema",
6+
"properties": {
7+
"schemaFormat": {
8+
"type": "string",
9+
"description": "Supported Schema format"
4110
},
42-
{
11+
"schema": {
4312
"type": "object",
44-
"description": "Multi format schema: OpenAPI Schema",
45-
"required": ["schemaFormat", "schema"],
46-
"not": {"required": ["$ref"]},
47-
"additionalProperties": false,
48-
"properties": {
49-
"schemaFormat": {
50-
"type": "string",
51-
"enum": [
52-
"application/vnd.oai.openapi;version=3.0.0",
53-
"application/vnd.oai.openapi+json;version=3.0.0",
54-
"application/vnd.oai.openapi+yaml;version=3.0.0"
55-
]
56-
},
57-
"schema": {
58-
"anyOf": [
59-
{
60-
"$ref": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json"
61-
},
62-
{
63-
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
64-
}
65-
]
66-
}
67-
}
13+
"description": "Schema definition"
6814
},
15+
"$ref": {
16+
"type": "string",
17+
"description": "Reference to schema"
18+
}
19+
},
20+
"minProperties": 1,
21+
"oneOf": [
6922
{
70-
"type": "object",
71-
"description": "Multi format schema: Json Schema",
72-
"required": ["schemaFormat", "schema"],
73-
"not": {"required": ["$ref"]},
74-
"additionalProperties": false,
75-
"properties": {
76-
"schemaFormat": {
77-
"type": "string",
78-
"enum": [
79-
"application/schema+json;version=draft-07",
80-
"application/schema+yaml;version=draft-07"
81-
]
23+
"description": "Because of $ref collision in Reference and AsyncAPI Schema(includes $ref from Json Schema)",
24+
"not": {"required": ["schemaFormat", "schema"]},
25+
"anyOf": [
26+
{
27+
"type": "object",
28+
"required": ["$ref"],
29+
"not": {"required": ["schemaFormat", "schema"]},
30+
"minProperties": 1,
31+
"maxProperties": 1,
32+
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
8233
},
83-
"schema": {
84-
"$ref": "http://json-schema.org/draft-07/schema"
34+
{
35+
"type": "object",
36+
"not": {"required": ["schemaFormat", "schema"]},
37+
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
8538
}
86-
}
39+
]
8740
},
8841
{
8942
"type": "object",
90-
"description": "Multi format schema: AsyncAPI Schema",
9143
"required": ["schemaFormat", "schema"],
9244
"not": {"required": ["$ref"]},
93-
"additionalProperties": false,
94-
"properties": {
95-
"schemaFormat": {
96-
"type": "string",
97-
"enum": [
98-
"application/vnd.aai.asyncapi;version=2.0.0",
99-
"application/vnd.aai.asyncapi+json;version=2.0.0",
100-
"application/vnd.aai.asyncapi+yaml;version=2.0.0",
101-
"application/vnd.aai.asyncapi;version=2.1.0",
102-
"application/vnd.aai.asyncapi+json;version=2.1.0",
103-
"application/vnd.aai.asyncapi+yaml;version=2.1.0",
104-
"application/vnd.aai.asyncapi;version=2.2.0",
105-
"application/vnd.aai.asyncapi+json;version=2.2.0",
106-
"application/vnd.aai.asyncapi+yaml;version=2.2.0",
107-
"application/vnd.aai.asyncapi;version=2.3.0",
108-
"application/vnd.aai.asyncapi+json;version=2.3.0",
109-
"application/vnd.aai.asyncapi+yaml;version=2.3.0",
110-
"application/vnd.aai.asyncapi;version=2.4.0",
111-
"application/vnd.aai.asyncapi+json;version=2.4.0",
112-
"application/vnd.aai.asyncapi+yaml;version=2.4.0",
113-
"application/vnd.aai.asyncapi;version=2.5.0",
114-
"application/vnd.aai.asyncapi+json;version=2.5.0",
115-
"application/vnd.aai.asyncapi+yaml;version=2.5.0",
116-
"application/vnd.aai.asyncapi;version=2.6.0",
117-
"application/vnd.aai.asyncapi+json;version=2.6.0",
118-
"application/vnd.aai.asyncapi+yaml;version=2.6.0",
119-
"application/vnd.aai.asyncapi;version=3.0.0",
120-
"application/vnd.aai.asyncapi+json;version=3.0.0",
121-
"application/vnd.aai.asyncapi+yaml;version=3.0.0"
122-
]
123-
},
124-
"schema": {
125-
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
126-
}
127-
}
45+
"minProperties": 2,
46+
"maxProperties": 2,
47+
"$ref": "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json"
12848
}
129-
],
130-
"$schema": "http://json-schema.org/draft-07/schema#",
131-
"$id": "http://asyncapi.com/definitions/3.0.0/anySchema.json"
49+
]
13250
}

definitions/3.0.0/components.json

+1-8
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@
1313
"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.",
1414
"patternProperties": {
1515
"^[\\w\\d\\.\\-_]+$": {
16-
"oneOf": [
17-
{
18-
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
19-
},
20-
{
21-
"$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json"
22-
}
23-
]
16+
"$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json"
2417
}
2518
}
2619
},

0 commit comments

Comments
 (0)