-
-
Notifications
You must be signed in to change notification settings - Fork 280
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
[2.0.0 REVIEW] Reusing channel definitions across files is hard #415
Comments
In that particular case, I was under the impression that we had to use the $ref that would refer to a message in a different file ("library")? A view property would seem to confuse the original intent of the application yml file to describe the application's publish/subscribe operations. |
I am just gonna spark the discussion with a suggestion to how we can solve this problem. I suggest we change the layout of channels to be an array rather then an object and add a operation keyword to keep the channel and operation on the same object. Also I would remove the publish and subscribe operation keywords and merge the operation item object into the channel item object. This however does comes at the cost of readability, however i think this is something that should be sacrificed for usability. If we find any other keywords which are unique depending on the operation this could easily be added to the same object. With the new setup you would define channels as such:
And enables referencing for channels as such:
Example.yaml
|
That's a great suggestion, @jonaslagoni. I foresee a couple of issues at a glance:
I've been working on a proposal some time ago but still have to find time to properly frame it. Will share as soon as possible. |
Yea I agree I dont like the array as well... But if we wanna stick to an Object we could maybe use some sort of key instead of channel name 🤔 ? and still move the channel name inside the object like in the example.
I dont understand? Cant it be achieved as the following: Example.yaml contains:
Which can then be referenced as |
Yes but nothing prevents you for doing something like: example:
example/: # channel, and keep the current object.
parameters: # Channel parameters
message: # Message for the channel regardless of operation
example2/:
parameters: # Channel parameters
message: # Message for the channel regardless of operation In this case, |
But with the proposed setup this would not be a valid file though 🤔 ? |
Sure. Just arguing that it's leaving a lot of room for failure. We should aim to make it less error prone. |
Ahh! Yes! Then I agree with you 😄 |
This issue has been automatically marked as stale because it has not had recent activity 😴 |
I'd say so, yes. |
It's currently very hard to reuse channel definitions across multiple AsyncAPI files. The reason is that they contain the operation definition too. An example:
The document above describes an
example
channel with thesubscribe
operation. If this AsyncAPI file was describing an internal broker-centric architecture, it would probably have many applications consuming messages from this channel and therefore the definition of these subscribers would be:As you can see, the only difference is the
publish
andsubscribe
verbs and possibly some other information related to the operation, like protocolbindings
,description
,summary
, etc. And the most important part,message
should belong to the channel, not the operation.This is a spec flaw because it's intermixing channels-related and application-related information, making it hard to extract into a separate file for reusability.
Proposal
Find a new way to define channels and operations. Possibly syntactically separated so we can leverage the
$ref
mechanism to improve reusability.The text was updated successfully, but these errors were encountered: