-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
feat!: allow multi format schemas #370
feat!: allow multi format schemas #370
Conversation
You have successfully added a new SonarCloud configuration ``. As part of the setup process, we have scanned this repository and found no existing alerts. In the future, you will see all code scanning alerts on the repository Security tab. |
4525afc
to
148d087
Compare
Thx smoja, i totaly like it! |
I found a point. The |
Kudos, SonarCloud Quality Gate passed! |
@smoya I am assuming you continue this when you get back the 19 th, otherwise let me know so I can help push this over the finish line 🙂 |
You are right assuming this. I'm gonna work on this. |
@GreenRover Sorry for the delay, but I can't find where we discussed about having those under components. We already have |
} | ||
], | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "http://asyncapi.com/definitions/3.0.0/messagePayloadObject.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call it something similar to MultiFormatSchemaObject
that is unrelated to payload
.
|
definitions/3.0.0/messageObject.json
Outdated
"payload": { | ||
"$ref": "http://asyncapi.com/definitions/3.0.0/messagePayloadObject.json" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be a union of the schema+format, just schema, or reference.
@jonaslagoni I made the changes you suggested. Additionally, I removed the BTW, I tested the compiled schema but I expected the following to give an error because the schema is not a valid avro but it doesn't. I will check the reason why. |
There is no direct need. May be reusability. |
"required": [ | ||
"schemaFormat" | ||
], | ||
"properties": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I miss a section that will allow protobuff, xsd or other string based schemas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we need to add official support for protobuf, indeed this should be done inside this document by adding a new "if" section. But afaik Otherwise, it is still supported since the schema for the object itself allows it since the schema
has no JSON Schema definition:
"properties": {
"schemaFormat": {
"type": "string"
},
"schema": {}
},
Meaning the following should be valid:
"components": {
"schemas": {
"myProtobufSchema": {
"schemaFormat": "application/vnd.google.protobuf;version=3",
"schema": "message Point {\n required int32 x = 1;\n required int32 y = 2;\n optional string label = 3;\n}\n\nmessage Line {\n required Point start = 1;\n required Point end = 2;\n optional string label = 3;\n}\n"
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "schema": {}
is the same as "schema": true
, so everything is allowed. Also stringed protobuf schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing, I noticed there is a bug somewhere in my current implementation where it is allowed to set a string schema even when setting the schemaFormat to be an AsyncAPI schema.
The following example demonstrates it; where the testinline
schema appears as invalid (as I expect) but the test
schema is valid (unexpected).
{
"asyncapi": "3.0.0",
"info": {
"title": "Example",
"version": "0.1.0"
},
"components": {
"schemas": {
"test": {
"schemaFormat": "application/vnd.aai.asyncapi+json;version=3.0.0",
"schema": "message Point {\n required int32 x = 1;\n required int32 y = 2;\n optional string label = 3;\n}\n\nmessage Line {\n required Point start = 1;\n required Point end = 2;\n optional string label = 3;\n}\n"
},
"testInline": "message Point {\n required int32 x = 1;\n required int32 y = 2;\n optional string label = 3;\n}\n\nmessage Line {\n required Point start = 1;\n required Point end = 2;\n optional string label = 3;\n}\n"
}
}
}
I don't get why since both are validating against schema.json
. I will need to check what's the issue about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smoya remember to change the components to be anySchema.json
not schema.json
😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"required": [ | ||
"schemaFormat" | ||
], | ||
"properties": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smoya remember to change the components to be anySchema.json
not schema.json
😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment
@jonaslagoni I had to add this change in order to allow values such as bool to be valid schemas when matched with "components": {
"schemas": {
"test": true,
"test2": {
"schema": true
},
"test3": {
"schemaFormat": "application/vnd.aai.asyncapi;version=3.0.0",
"schema": true
}
}
} Do you believe there is a better/smarter way of doing that? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👌
definitions/3.0.0/anySchema.json
Outdated
@@ -0,0 +1,21 @@ | |||
{ | |||
"allOf": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is allOf
needed here? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. Removed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢 🇮🇹
Kudos, SonarCloud Quality Gate passed! |
/rtm |
🎉 This PR is included in version 6.0.0-next-major-spec.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
This PR contains all the required changes for the following new Spec v3.0.0 feature asyncapi/spec#622.
A WIP PR containing changes on the spec has been created by @GreenRover.
The changes made in this PR apply to:
Related issue(s)
asyncapi/spec#622