Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong validation with AsyncAPI v3 in VS Code and JetBrains IDEs #495

Merged
merged 21 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0396524
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 10, 2024
8af32be
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 10, 2024
518e3e0
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 11, 2024
78ce54d
Merge branch 'master' into fix/494
Pakisan Mar 12, 2024
b5f2139
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 12, 2024
87a6097
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 12, 2024
981c80d
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 12, 2024
212cc82
Merge branch 'master' into fix/494
Pakisan Mar 15, 2024
e8ee4a2
Merge branch 'master' into fix/494
Pakisan Mar 19, 2024
b573b54
Update .gitignore
Pakisan Mar 19, 2024
62c5193
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 19, 2024
297e778
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 19, 2024
dddb3d3
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 22, 2024
a4c5ef0
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 25, 2024
acfb26e
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 25, 2024
469431c
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 28, 2024
b45e610
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 28, 2024
52b06c5
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Mar 29, 2024
d34130d
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Apr 2, 2024
a9a7d47
fix: AsyncAPI v3 shows warning in Studio and IntelliJ plugin when ref…
Pakisan Apr 2, 2024
eba77ed
Merge branch 'master' into fix/494
smoya Apr 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules
.nyc_output
.vscode
coverage
coverage

.DS_Store
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think these changes with additionalProperties is necessary, and on the other side, are you not allowed to have additional properties in Avro? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I remember Avro is allows only defined attributes. For example Record - https://avro.apache.org/docs/1.11.1/specification/#schema-record

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like additional properties is allowed on the different levels of Avro: https://asyncapi.slack.com/archives/C0230UAM6R3/p1712059889567579?thread_ts=1711713980.293369&cid=C0230UAM6R3

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed restriction

},
"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
31 changes: 18 additions & 13 deletions definitions/3.0.0/anySchema.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
{
"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.",
"$id": "http://asyncapi.com/definitions/3.0.0/anySchema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"$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",
"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"
}
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meant the entire thing @Pakisan, anySchema does not need any changes to work 🙂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
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"
Pakisan marked this conversation as resolved.
Show resolved Hide resolved
}
}
},
Expand Down
51 changes: 13 additions & 38 deletions definitions/3.0.0/multiFormatSchema.json
Original file line number Diff line number Diff line change
@@ -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": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want, feel free to remove this if/then as #507 does ✌️

"not": {
"type": "object"
Expand All @@ -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.",
Expand All @@ -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": [
Expand All @@ -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"
}
}
}
Expand Down Expand Up @@ -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"
}
}
}
Expand All @@ -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"
}
}
}
Expand Down
Loading
Loading