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

messageTrait not applied when message not used in a channel #210

Closed
c-pius opened this issue Dec 10, 2020 · 4 comments · Fixed by #214
Closed

messageTrait not applied when message not used in a channel #210

c-pius opened this issue Dec 10, 2020 · 4 comments · Fixed by #214
Labels

Comments

@c-pius
Copy link
Contributor

c-pius commented Dec 10, 2020

Description

We want to integrate the react component into our project for displaying specifications of messages to be implemented. Because the messages are not implemented but only specified by us, we define them only in the components/messages section and don't use the channels section (passing an empty object).

However, if the message is not referenced from a channel, it doesn't apply the used messageTraits to the message.

Expected result

Message traits should be applied to the message even if the message is not used in channel. All properties from the used trait should be shown as part of the message.

Actual result

Message trait is only applied if the message is used within a channel. In the case the message is used in a channel, you can see the properties from the trait in both the channel, and the message object.

Steps to reproduce
Find a minimal example here. The "light measured" message is used in a channel and the "commonHeaders" trait is applied correctly ("my-app-header" property shown in the channel and the message).

The "turn off" message is not used in a channel. The "commonHeaders" trait is NOT applied and you won't find the headers section with the "my-app-header" property.

message-channel-trait-example.txt

Troubleshooting

@github-actions
Copy link

Welcome to AsyncAPI. Thanks a lot for reporting your first issue.

Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@derberg
Copy link
Member

derberg commented Dec 10, 2020

@c-pius Hey, thanks for reporting. I will move this issue under parser-js repo as it is the responsibility of the parser to apply traits according to the spec and this component just uses the parser.

Problem is here. We apply traits only to messages under operations as you wrote. Looking quickly into code looks like we just need to use applyTraits function here as well, on components.messages only.

It would be awesome if you could craft a PR for this

@derberg derberg transferred this issue from asyncapi/asyncapi-react Dec 10, 2020
@github-actions
Copy link

Welcome to AsyncAPI. Thanks a lot for reporting your first issue.

Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 1.3.1 🎉

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants