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

Something went wrong: Template render error #10

Closed
josejamilena opened this issue Apr 2, 2020 · 4 comments
Closed

Something went wrong: Template render error #10

josejamilena opened this issue Apr 2, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@josejamilena
Copy link

Hi. I'm trying to generate code, but I don't understand the error in the template. Could you check if it's my problem or if there's a problem with the template?

Something went wrong: Template render error: (C:\Users\JAMILENADAZJ\eclipse-workspace\asyncapi\tmp\node_modules\@asyncapi\java-spring-cloud-stream-template\template\src\main\java\$$schema$$.java) [Line 53, Column 12] TypeError: Cannot read property 'items' of undefined at Object._prettifyError (C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\lib.js:36:11) at C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:561:19 at eval (eval at _compile (C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:29:11) at C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:611:9 at Template.root [as rootRenderFunc] (eval at _compile (C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:740:3) at Template.getExported (C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:609:10) at eval (eval at _compile (C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:28:5) at Environment.getTemplate (C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:277:9) at eval (eval at _compile (C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:26:5) at eval (eval at _compile (C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:23:1) at fn (C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\a-sync-waterfall\index.js:26:24) at C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\a-sync-waterfall\index.js:66:22 at executeSync (C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\a-sync-waterfall\index.js:8:15) at C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\a-sync-waterfall\index.js:65:11 at eval (eval at _compile (C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:18:1) at C:\Users\JAMILENADAZJ\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:569:11

node --version ==> v12.16.1
Launch command ==> ag --force-write ..\AsyncAPI-2.0.0.yaml https://github.com/asyncapi/java-spring-cloud-stream-template.git

The asyncAPI I've defined is this
AsyncAPI-2.0.0.yaml.zip

Thanks.

@github-actions
Copy link

github-actions bot commented Apr 2, 2020

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 Apr 2, 2020

Hi Jose. The reason it fails is that you do not have fully correct AsyncAPI document.
In your document, in Server Object you specified Security Requirement Object

    security:
      - apiKey: []
      - supportedOauthFlows:
        - streetlights:on
        - streetlights:off
        - streetlights:dim
      - openIdConnectWellKnown: []

According to the spec:

The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the Components Object.

You are basically missing Security Scheme Object in Components Object. For some valid example of how to do it properly, you could have a look here

@josejamilena I hope that helps, let me know


What is concerning me here though is, that the error you got was on a template lever, not parse level. For the parser your document is fine, which I don't believe it is true if the spec says securitySchemes is a must.
@fmvilas what you think, I think it is a bug in the parser and that in this case it is parser responsibility to validate it. I would move this bug under the parser repo, what say you? Error will occur in other templates too, like HTML -> https://playground.asyncapi.io/

@derberg derberg added the bug Something isn't working label Apr 2, 2020
@fmvilas
Copy link
Member

fmvilas commented Apr 2, 2020

Agree @derberg. I just listed it here: asyncapi/parser-js#10. Thanks!

@josejamilena
Copy link
Author

Thanks @derberg and @fmvilas , I Will try it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants