-
-
Notifications
You must be signed in to change notification settings - Fork 295
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
[FEATURE REQUEST] Add support for multiple schema formats #113
Comments
Updated the description with a proposal ☝️ |
@fmvilas why the support for multiple schema formats? I think this adds more complexity to the spec with no much value. Do you have any use case for this? EDIT: I mean why multiple schemas formats on the same payload. In this case we'll need to make sure all formats are valid at the same time and I'm not really seen why someone would want to define multiple formats at a time channels:
user/created:
subscribe:
headers:
application/x-protobuf:
$ref: 'path/to/user-created.proto#Headers'
payload:
application/x-protobuf:
$ref: 'path/to/user-created.proto#UserCreated'
application/schema+json;version=draft-07:
$ref: 'path/to/user-created.json'
application/vnd.oai.openapi;version=3.0.1#/components/schemas/UserCreated:
$ref: 'path/to/user-created.json'
avro:
$ref: 'path/to/user-created.avro' |
Good point. I'll limit them to just one. People can always create overlays (#107) if they want to change some message format. |
yeah, I've seen in event-driven architectures is more common to pass one format and have others processes/bus to do transformation :) |
🎉 This issue has been resolved in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Is your feature request related to a problem? Please describe.
Some users complain because they're already using Avro or Google's protobuf, and don't want to maintain the definitions in both formats, e.g., protobuf and JSON schema. Users want to reuse their definitions without having to make weird tricks.
Can't it be tackled using specification extensions?
Absolutely. But it would require having schemas defined as "empty objects" and then a specification extension providing the real value. While this is possible, it's a weird trick, because the JSON schema definition doesn't match the, for instance, protobuf definition.
Describe the solution you'd like
See the proposal below.
Describe alternatives you've considered
Using specification extensions.
Additional context
Unlike HTTP APIs, message-oriented architectures use a wide variety of protocols and message formats. We should embrace them and don't stick too heavily to JSON schema.
Proposal
My proposal is to insert a new key into
headers
andpayload
. The key name will represent the schema format and its value will depend on the schema format.Examples
Same document but using $ref's.
Specifying multiple schema formats is forbidden. The following is NOT VALID:
Notice the usage of URI fragments to point to a specific Proto message.
Discarded solutions
Other solutions have been considered but discarded:
The text was updated successfully, but these errors were encountered: