feat!: allow multi format schemas#370
feat!: allow multi format schemas#370asyncapi-bot merged 17 commits intoasyncapi:next-major-specfrom
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.
I would call it something similar to MultiFormatSchemaObject that is unrelated to payload.
|
| "payload": { | ||
| "$ref": "http://asyncapi.com/definitions/3.0.0/messagePayloadObject.json" | ||
| } |
There was a problem hiding this comment.
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.
I miss a section that will allow protobuff, xsd or other string based schemas?
There was a problem hiding this comment.
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.
the "schema": {} is the same as "schema": true, so everything is allowed. Also stringed protobuf schema.
There was a problem hiding this comment.
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.
@smoya remember to change the components to be anySchema.json not schema.json 😄
| "required": [ | ||
| "schemaFormat" | ||
| ], | ||
| "properties": { |
There was a problem hiding this comment.
@smoya remember to change the components to be anySchema.json not schema.json 😄
|
@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? |
definitions/3.0.0/anySchema.json
Outdated
| @@ -0,0 +1,21 @@ | |||
| { | |||
| "allOf": [ | |||
|
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