Closed DavidBiesack closed 2 years ago
Looks like the issue is with the fact that template is not supporting oneOf
end expects a single message on a operation -> https://github.com/asyncapi/nodejs-template/blob/master/template/src/api/routes/%24%24channel%24%24.js#L14
@derberg template/src/api/handlers/$$channel$$.js
uses channel.publish().message(0)
--- should src/api/routes/$$channel$$.js
use channel.publish().message(0)
and channel.subscribe().message(0)
as well, instead of message()
?
(I tried that patch in my fork of the repo and it appears to work - let me know and I can submit a PR)
Or should the message()
function detect when the message
is an oneOf
, and default to message(0)
if no index is passed? I don't know enough about the generator to know where that message()
function is defined.
However, I don't see how nodejs-template really deals with the arrays if it only processes message(0)
and not message(1)
through message(n-1)
- thoughts on this?
@DavidBiesack these are the functions related to message that you can use: https://github.com/asyncapi/parser-js/blob/master/lib/models/operation.js
message
should have index if oneOf
is used. So best is always to check with hasMultipleMessages
if oneOf
is available and then work it out with messages
that returns an array of messages, and then process one by one.
Hmm, nodejs-template does not use hasMultipleMessages
anywhere ☹️
I'll have to see how others do it. What is the most "mature" (complete) generator plugin?
https://github.com/search?q=org%3Aasyncapi+hasMultipleMessages&type=code shows html-template and markdown-template use it (so there is an example) but none of the real code generators.
Without really knowing what nodejs-template is trying to do, I'm not comfortable trying to extend it to use hasMultipleMessages
This issue has been automatically marked as stale because it has not had recent activity :sleeping: 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 :heart:
This issue has been automatically marked as stale because it has not had recent activity :sleeping: 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 :heart:
I submitted a feature request JS Parser. https://github.com/asyncapi/parser-js/issues/372 for returning one single JSON schema for generators to access and let the JSON Schema validation handle the oneOf
processing.
I updated the code with a TODO note to update when that feature is implemented.
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
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 :heart:
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
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 :heart:
@derberg is it possible to merge the or and close this?
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
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 :heart:
@DavidBiesack just approved PR, please have a look 🙏🏼
:tada: This issue has been resolved in version 0.12.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Describe the bug
When a channel uses
oneOf
instead of a single message, the generator fails with Error: Unable to callthe return value of (the return value of (channel["publish"])["message"])["name"]
, which is undefined or falseyHow to Reproduce
Copy the sample from https://www.asyncapi.com/docs/tutorials/streetlights but use oneOf (as a precursor to publishing multiple events to that channel).
Source:
run:
Expected behavior
iterator over all the messages in the
oneOf