Skip to content
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

No functions to access message and operation traits #226

Closed
jonaslagoni opened this issue Jan 16, 2021 · 10 comments · Fixed by #357
Closed

No functions to access message and operation traits #226

jonaslagoni opened this issue Jan 16, 2021 · 10 comments · Fixed by #357
Labels
enhancement New feature or request good first issue Good for newcomers released

Comments

@jonaslagoni
Copy link
Member

Reason/Context

Even though we provide access to message and operation traits if listed in the components sections, there exist no functions on the operation and message objects themselves to access traits if you use the parser with the option applyTraits = false.

Description

I would expect functions such as the following to be available:
Message trait: asyncapi.channel('mychannel').publish().message().traits();
Operation trait: asyncapi.channel('mychannel').publish().traits();

It is possible to access the traits using the following
Message trait: asyncapi.channel('mychannel').publish().message()._json.traits
Operation trait: asyncapi.channel('mychannel').publish()._json.traits

Up for discussion:
If the traits are already applied, would you really want access to the original traits 🤔 ?

@jonaslagoni jonaslagoni added the enhancement New feature or request label Jan 16, 2021
@derberg
Copy link
Member

derberg commented Jan 18, 2021

If the traits are already applied, would you really want access to the original traits 🤔 ?

This was exactly my question after reading the context section. What is the use case here really?

@jonaslagoni
Copy link
Member Author

jonaslagoni commented Jan 18, 2021

@derberg You wouldn't IMO, however as stated you have no way to access those traits (without accessing the underlying json schema) if you for example parse an AsyncAPI document with the option applyTraits = false.

@derberg
Copy link
Member

derberg commented Jan 18, 2021

oh, you found the use case, if we allow applyTraits = false we should also enable easy access to traits

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
Thank you for your contributions ❤️

@github-actions github-actions bot added the stale label Mar 20, 2021
@magicmatatjahu
Copy link
Member

@derberg @jonaslagoni We have option to access to traits by x-parser-original-traits extension here, so we only must write API for that :)

@derberg derberg removed the stale label Apr 7, 2021
@github-actions
Copy link

github-actions bot commented Jun 7, 2021

This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
Thank you for your contributions ❤️

@github-actions
Copy link

github-actions bot commented Aug 7, 2021

This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
Thank you for your contributions ❤️

@github-actions github-actions bot added the stale label Aug 7, 2021
@derberg derberg added good first issue Good for newcomers and removed stale labels Aug 9, 2021
@KhudaDad414
Copy link
Member

KhudaDad414 commented Sep 7, 2021

@magicmatatjahu if someone wants to access traits with {applyTraits: false} then there won't be any x-parser-original-traits there. so the core issue is still there. can I add these two functions? I really need them right now :)

@magicmatatjahu
Copy link
Member

@KhudaDad414 Exactly, won't be, but will be the native traits object :) The traits object is only deleted with {applyTraits: true} (code), so you should check first the x-parser-original-traits extension and then as a fallback check the traits field :) You can create PR, if you asked for it :)

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 1.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants