-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
conditionalFiles only works if you are lucky #358
Comments
One thing sure here is that current conditionalFiles in nodejs-template do not make sense as files listed there do not exist in the tempalate anyway https://github.com/asyncapi/nodejs-template/blob/master/package.json#L88 |
After some investigation:
and if I generate service using my mqtt server, the file is not generated -> this is what I expected I'm more concerned about:
|
@Tenischev |
@Tenischev I tried to replace your hook by configuration in java-template but you do not support |
We could also have a nice warning for template developers in template config validation so they know they have wrong conditions, for files that do not exist. That would be a separate feature issue though |
@Tenischev I created a PR for java, have a look and tell me what you think https://github.com/asyncapi/java-spring-template/pull/55/files |
@Tenischev I created PR for docs in generator #363 @fmvilas have a look on my comment
|
Yeah, I think it totally should 👍 |
@fmvilas PR ready for review @Tenischev |
Hey @derberg , |
@Tenischev well, the current description of the I've extended my PR with more explanation, examples and links. What do you think? |
🎉 This issue has been resolved in version 0.52.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Describe the bug
conditionalFiles
in docs is incomplete and example is actually pitfall.subject
is not resolved in AsyncAPI, then file will be rendered because of this conditionHow to Reproduce
Just try to use provided example
Expected behavior
tempalte
foldersubject
is not found in AsyncAPI, then file is not renderedvalidation
is not anyJSON Schema Draft 07 object
, it must be fromJSON Schema Validation
Correct
subject
path in term of AsyncAPI spec to server protocols will beservers.*.protocol
, but result of this (and any other) resolution will be an array, you should take it into account. Since it's not possible to predict how much servers will be in user AsyncAPI, usage ofconst
is not possible as is. Perhaps,contains
should be used always to check against result array.Here an example of
validation
that will correctly check for themqtt
protocol{ "contains": { "type": "string", "const": "mqtt" }}
.Or another approach where filtering delegated to
subject
-"subject": "servers.*.{protocol: protocol} | [?protocol=='mqtt']", "validation": { "const": [ { "protocol": "mqtt" } ] }
Hint
Perhaps we have a bug in nodejs template because it's exact copy of example from cuurent doc
The text was updated successfully, but these errors were encountered: