Comments (27)
Clarifying the rules we want to add:
- If the operation is required (under root
operations
), the operation channel must only point to a required channel (under rootchannels
). - If the operation is optional (under
components
), the operation channel can point either to a required channel (under rootoperations
) or to an optional channel (undercomponents
). - The messages, no matter where they are located, have to point to messages from the channel specified in the field channel.
Are we aligned?
cc @fmvilas @derberg @jonaslagoni and anyone interested
from spec.
@buehlefs The following sentence located in the description of the Operation Trait object is wrong (nice catch!):
This object MAY contain any property from the Operation Object, except the action, channel and traits ones.
Source: https://www.asyncapi.com/docs/reference/specification/v3.0.0-next-major-spec.16#operationTraitObject
If you take a look at the fields an Operation Trait object has, messages
field is not included.
You can confirm this is by design and expected by checking its corresponding JSON Schema definition at https://github.com/asyncapi/spec-json-schemas/blob/next-major-spec/definitions/3.0.0/operationTrait.json.
We should fix that sentence. (I created the following issue so we work on it asap #994)
from spec.
we have similar situation with channel.servers
where servers is an array of $ref pointers. Such $ref should always point to the root server
and not components/server
so in general, we need to add one new sentence to servers under channels
, messages under operation and operation reply
, channels under operation and operation reply
suggested edit, for channel:
#current text:
A $ref pointer to the definition of the channel in which this operation is performed
#suggested edit
A $ref pointer to the definition of the channel in which this operation is performed. It MUST point to channel definition located in [Channels Object](#channelsObject) and MUST NOT point to channel definition located in [Components Object](#componentsObject)
#I know first must make it clear that components are not allowed, but I think better to be explicit like this
above example can of course be easily modified and for messages will for example sound
#current
A list of $ref pointers pointing to the supported [Message Objects](https://github.com/asyncapi/spec/blob/next-major-spec/spec/asyncapi.md#messageObject) that can be processed by this operation. It MUST contain a subset of the messages defined in the [channel referenced in this operation](https://github.com/asyncapi/spec/blob/next-major-spec/spec/asyncapi.md#operationObjectChannel).
#new
A list of $ref pointers pointing to the supported [Message Objects](#messageObject) that can be processed by this operation. It MUST contain a subset of the messages defined in the [channel referenced in this operation](#operationObjectChannel). Individual $ref pointer MUST point to message definition located in the [channel referenced in this operation](#operationObjectChannel) and MUST NOT point to message definition located in [Components Object](#componentsObject)
from spec.
All parser-js required Spectral rules are now merged and enabled in next-major-spec
from spec.
That makes sense to me yea 🤔
from spec.
Yes, that makes sense to me as well.
from spec.
How should this interact with operation traits that specify a message? Only allowing references to messages in a specific channel for them would limit their reusability.
from spec.
@buehlefs could you visualize a problem with an example? message trait is used usually when messageTrait
keeps entire message definition, without references, and also messageTrait
is something you use on message
level 🤔 you would anyway add it in channel.message right?
from spec.
@fmvilas @jonaslagoni be aware that it can affect release date, unless we get help to make sure that is supported in parser-js and converter-js. Probably examples need a review. Nevertheless, better to add this limitation now, and relax with 3.1 or 3.2, cause other way around it will be a breaking change
from spec.
@derberg I am talking about an operationTrait
object that can "contain any property from the Operation Object, except the action, channel and traits" (as per current pre release spec). I can see this being used to specify a login (or haertbeat) operation with a login message that will be used in multiple locations with different channels. But this reuse would only be possible if the message is referenced from components and not from a specific channel. (but I may be missing something here)
from spec.
@derberg @fmvilas I'm gonna start working on the validation for this in Parser-JS. We would need to add an Spectral rule to check that.
Btw, we do not have particular rules for v3 implemented atm besides the standard ruleset.
In case any of you think other must-have rules are missing, please mention it in an issue so we can work on it.
from spec.
Awesome! Thanks, @smoya!
I was wondering today if we shouldn't apply a similar rule to the channel
field in an operation. It should only be allowed to point to a channel in the channels
section and not to a channel in components/channels
or in another file or URL. Does that make sense?
It should be applied to the spec, JSON schemas, and the parser.
from spec.
Probably a good idea 🤔
from spec.
Awesome! Thanks, @smoya!
I was wondering today if we shouldn't apply a similar rule to the
channel
field in an operation. It should only be allowed to point to a channel in thechannels
section and not to a channel incomponents/channels
or in another file or URL. Does that make sense?It should be applied to the spec, JSON schemas, and the parser.
Yup, good catch
from spec.
I was wondering today if we shouldn't apply a similar rule to the
channel
field in an operation. It should only be allowed to point to a channel in thechannels
section and not to a channel incomponents/channels
or in another file or URL. Does that make sense?
I gave this another thought and I think this shouldn't happen. What happens with channels and linked operations declared under components?
Consider the following components in an AsyncAPI v3 doc:
components:
channels:
aChannel:
messages:
aMessage:
$ref: '#/components/messages/aMessage'
operations:
anOperation:
action: send
channel:
$ref: '#/components/channels/aChannel'
messages:
- $ref: '#/components/channels/aChannel/messages/aMessage'
You can see the anOperation
refers to the aChannel
channel, also in components. Same with its message.
If we force those to always refer to channels from #/channels
, the use case above won't be valid.
I believe the current description of the messages
field of an Operation is already telling us what should be the enforcements:
It MUST contain a subset of the messages defined in the channel referenced in this operation
If the channel is located under #/channels
or rather #/components/channels
is not important here if we always keep that consistency in referenced messages under messages
field.
cc @fmvilas @jonaslagoni @derberg
from spec.
Yes, that's exactly what I mean.
from spec.
The messages, no matter where they are located, have to point to messages from the channel specified in the field channel.
1/3 rules created: asyncapi/parser-js#911
from spec.
- If the operation is optional (under
components
), the operation channel can point either to a required channel (under rootoperations
) or to an optional channel (undercomponents
).
Actually this won't be considered as a rule because there is nothing to validate here, right?
from spec.
If the operation is required (under root operations), the operation channel must only point to a required channel (under root channels).
Second rule created: smoya/parser-js#5
However, it is located in my fork, because all needed scaffolding for enabling Spectral rules for v3 are added into the opened PR asyncapi/parser-js#911. Once is merged, I will close and open a new PR against AsyncAPI repo.
But feel free to review anyway please.
from spec.
we have similar situation with
channel.servers
where servers is an array of $ref pointers. Such $ref should always point to the rootserver
and notcomponents/server
Good catch again. I will create the proper Spectral rule as well.
from spec.
I will create the proper Spectral rule as well.
Done. Added into the same previous PR asyncapi/parser-js#913
from spec.
above example can of course be easily modified and for messages will for example sound
I don't think we need to change that. It sounds pretty clear to me, specially now that we will update the channel
operation field to be explicit about where should it point to.
It MUST contain a subset of the messages defined in the channel referenced in this operation
from spec.
@smoya but current text is not clear that $ref pointer must point to the channel - it only says the message must be the same (but it is not explicit - even for us as even our converter do not convert properly)
from spec.
Let's move this discussion into #996
from spec.
We are missing the Spectral rules for OperationReply.channel
and OperationReply.messages
.
They should validate that:
- messages are pointing to a subset of messages of the
OperationReply.channel
- channel should point to:
- root channel if the OperationReply is under root Operation
- either root channel or component channel if the OperationReply is under components Operation or under components Replies.
Does it make sense?
from spec.
I think it does, yeah 👍
from spec.
This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience ❤️
from spec.
Related Issues (20)
- Confusing Operation Object Example HOT 2
- Invite Heiko Henning to join as code owner HOT 11
- Should the Reply Object extend from the Operation Object? HOT 5
- Channel parameter type HOT 2
- Send/Receive again confusion HOT 3
- AsyncAPI v3 retrospective HOT 1
- Undefined description when using `OneOf`, `AllOf` or `AnyOf` HOT 3
- Undefined behaviour of "messageId" for Message Traits and Messages defined in components. HOT 4
- Avro specification inside AsycnApi file HOT 4
- Server Object host field compatibility with protocols HOT 3
- testing -input command not found HOT 2
- Possible bug with example - adeo-kafka-request-reply-asyncapi HOT 17
- Decide what to do with OAS schema properties HOT 4
- Allow plain `string` in Message Example Object field payload for non-json payloads (like xml, yaml) HOT 6
- when to finish amqp serverBindings HOT 1
- Divide "Maintainer" role into two categories: Triager and Committer HOT 7
- How to define MQTT User Properties in an AsyncAPI document? HOT 1
- Extend Avro and OpenAPI schema versions HOT 13
- Multiple reply addresses HOT 2
- Can i document an endpoint for a cron job? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spec.