fix: make key
in kafka msg binding validate as anyOf
#466
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Kafka binding for messages, in 0.4 version introduced Avro support for
key
- but JSON Schema is not properly modifiedKafka message binding -> https://github.com/asyncapi/bindings/tree/master/kafka#message-binding-object
so things like below should be allowed:
Just go to https://studio.asyncapi.com/?url=https://raw.githubusercontent.com/asyncapi/spec/d78dcea70c9b094a3df72f9a4e811828cec778cc/examples/adeo-kafka-request-reply-asyncapi.yml and try to remove lines 242-245 all all suddenly validation stops failing
Where issue is coming from
This is what json schema for message binding says: https://github.com/asyncapi/spec-json-schemas/blob/master/bindings/kafka/0.4.0/message.json#L13-L21
current JSON Schema validates agains
oneOf
listed schemas, but problem is that these are reference object + json schema. JSON schema defines$ref
property as well, so when inkey
you put$ref
, it is then valid against both schemas listed underoneOf
and yeah, it is an error.I don't think there is a better solution than just using
anyOf
instead ofoneOf
🤔Also, such validation combination like the one I fix, is used in many other bindings, so also not sure but maybe I should propagate the fix everywhere?
This PR fixes
oneOf
toanyOf