asyncapi / java-spring-template

Java Spring template for the AsyncAPI Generator
Apache License 2.0
66 stars 53 forks source link

array with ref and Enumeration with dash Generation failed #83

Closed panosgit closed 3 years ago

panosgit commented 3 years ago

Hello, I am trying to generate a client from a yaml and i am getting the error below

something went wrong:
Template render error: (C:\Users\myUser\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\@asyncapi\java-spring-template\template\src\main\java\com\asyncapi\model\$$schema$$.java) [Line 21, Column 29]
  Error: Unable to call `the return value of (prop["items"])["format"]`, which is undefined or falsey
    at Object._prettifyError (C:\Users\myUser\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\lib.js:36:11)
    at C:\Users\myUser\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:561:19
    at Template.root [as rootRenderFunc] (eval at _compile (C:\Users\myUser\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:1180:3)
    at Template.render (C:\Users\myUser\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:550:10)
    at Environment.renderString (C:\Users\myUser\AppData\Roaming\npm\node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:378:17)
    at C:\Users\myUser\AppData\Roaming\npm\node_modules\@asyncapi\generator\lib\generator.js:595:21
    at new Promise (<anonymous>)
    at Generator.renderString (C:\Users\myUser\AppData\Roaming\npm\node_modules\@asyncapi\generator\lib\generator.js:594:12)
    at Generator.renderFile (C:\Users\myUser\AppData\Roaming\npm\node_modules\@asyncapi\generator\lib\generator.js:618:17)
    at async Generator.generateSeparateFile (C:\Users\myUser\AppData\Roaming\npm\node_modules\@asyncapi\generator\lib\generator.js:534:21)

After removing the $ref: '#/components/schemas/iAmAnArrayWithRefThatWillNotLetYouGenerate' and setting inline the object the generation was successfull.

Another issue is that after the generation if I have an enumeration with Dash '-' then it is not replaced with an underscore

Could you please investigate it when you have some time?

Ps i am attaching you the yaml file in a TXT format as it does not let me attach it as a yaml failingExample.yaml.txt

github-actions[bot] commented 3 years ago

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.

Tenischev commented 3 years ago

Hi @panosgit I'm not sure which JSON result you would like to have by combining type: array and $ref:

        iAmAnArrayWithRefThatWillNotLetYouGenerate:
          type: array
          minItems: 0
          $ref: '#/components/schemas/iAmAnArrayWithRefThatWillNotLetYouGenerate'

Did you miss items: before $ref?

Regarding wrong enum generation, i'll take it with me.

asyncapi-bot commented 3 years ago

:tada: This issue has been resolved in version 0.19.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: