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

HTML generator not handling circular references correctly #939

Closed
synaos-bwi opened this issue Apr 13, 2023 · 6 comments
Closed

HTML generator not handling circular references correctly #939

synaos-bwi opened this issue Apr 13, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@synaos-bwi
Copy link

synaos-bwi commented Apr 13, 2023

Describe the bug

A message that contains a payload with a circular reference is not named correctly, but is named with N being an integer.

VERSION
@asyncapi/cli/0.30.2 win32-x64 node-v16.13.0

How to Reproduce

Call the following CLI command on the attached minimal reproducible example (MRE) and examine the generated html file:
asyncapi generate fromTemplate ./cycle-mwe.yml @asyncapi/html-template -o test.html --force-write

asyncapi: 2.5.0
info:
  title: storage API
  version: '0.0.1'
channels:
  toy.events:
    subscribe:
      message:
          $ref: '#/components/messages/toyCollectionFilled'
 
components:
  messages:
    toyCollectionFilled:
      payload:
        $ref: '#/components/schemas/ToyCollection'
 
  schemas:
    ToyCollection:
      type: object
      description: generic toys
      properties:
        Matryoshkas:
          type: array
          items:
            $ref: '#/components/schemas/Matryoshka'
        dolls:
          type: array
          items:
            $ref: '#/components/schemas/Doll'
    Matryoshka:
      description: a container for toys
      type: object
      properties:
        id:
          type: string
        content:
          $ref: '#/components/schemas/ToyCollection'
    Doll:
      type: object
      properties:
        name:
          type: string

Note: If the content property of Matryoshka in the MRE is commented out, the circluar dependency is removed and the message is named correctly.

Expected behavior

The message is named correctly as stated in the spec file.

@synaos-bwi synaos-bwi added the bug Something isn't working label Apr 13, 2023
@github-actions
Copy link
Contributor

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@magicmatatjahu
Copy link
Member

@synaos-bwi Could you point me where you have problem?

image

I see something like that, where is named with N being an integer value?

If you don't see that, please upgrade the generator and/or html template to the latest version.

@synaos-bwi
Copy link
Author

synaos-bwi commented Apr 13, 2023

Using the asyncapi-cli seemed to have used a slightly older version of the generator, but even when calling the most recent genereator directly, I still have the same problem:
image

My versions and commands:
image

Adding the --debug flag to the generator states:

$ ag --debug cycle-mwe.yml @asyncapi/html-template -o output2 --force-write
Unable to resolve template location at undefined. Package is not available locally. Error: Cannot find module '@asyncapi\html-template\package.json'
Require stack:
- C:\Users\<USER>\AppData\Roaming\npm\node_modules\noop.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (C:\nvm\v16.13.0\node_modules\@asyncapi\generator\node_modules\@cspotcode\source-map-support\source-map-support.js:811:30)
    at resolveFileName (C:\nvm\v16.13.0\node_modules\@asyncapi\generator\node_modules\resolve-from\index.js:29:39)
    at resolveFrom (C:\nvm\v16.13.0\node_modules\@asyncapi\generator\node_modules\resolve-from\index.js:43:9)
    at module.exports (C:\nvm\v16.13.0\node_modules\@asyncapi\generator\node_modules\resolve-from\index.js:46:47)
    at utils.getTemplateDetails (C:\nvm\v16.13.0\node_modules\@asyncapi\generator\lib\utils.js:206:30)
    at C:\nvm\v16.13.0\node_modules\@asyncapi\generator\lib\generator.js:367:26
    at new Promise (<anonymous>)
    at Generator.installTemplate (C:\nvm\v16.13.0\node_modules\@asyncapi\generator\lib\generator.js:360:12)
    at Generator.generate (C:\nvm\v16.13.0\node_modules\@asyncapi\generator\lib\generator.js:180:73)
    at Generator.generateFromString (C:\nvm\v16.13.0\node_modules\@asyncapi\generator\lib\generator.js:266:17)
    at async C:\nvm\v16.13.0\node_modules\@asyncapi\generator\cli.js:154:9 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\<USER>\\AppData\\Roaming\\npm\\node_modules\\noop.js'
  ]
}
Template installation started because the template cannot be found on disk.
Template @asyncapi/html-template successfully installed in C:\nvm\v16.13.0\node_modules\@asyncapi\generator\node_modules\@asyncapi\html-template.
Version of used template is 0.28.3.
File C:\PATH/TO/SPEC\output2\index.html couldn't be found. Error: ENOENT: no such file or directory, stat 'C:\PATH/TO/SPEC\output2\index.html'
File C:\PATH/TO/SPEC\output2\js\asyncapi-ui.min.js couldn't be found. Error: ENOENT: no such file or directory, stat 'C:\PATH/TO/SPEC\output2\js\asyncapi-ui.min.js'
File C:\PATH/TO/SPEC\output2\css\asyncapi.min.css couldn't be found. Error: ENOENT: no such file or directory, stat 'C:\PATH/TO/SPEC\output2\css\asyncapi.min.css'
File C:\PATH/TO/SPEC\output2\css\global.min.css couldn't be found. Error: ENOENT: no such file or directory, stat 'C:\PATH/TO/SPEC\output2\css\global.min.css'

Done! ✨
Check out your shiny new generated files at 

@derberg
Copy link
Member

derberg commented May 15, 2023

please try to add name or messageId to the message under component.

or, try to install AsyncAPI CLI and run generator like

asyncapi generate fromTemplate cycle-mwe.yml @asyncapi/html-template -o output2 --force-write

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity 😴

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 ❤️

@github-actions github-actions bot added the stale label Sep 13, 2023
@derberg
Copy link
Member

derberg commented Oct 25, 2023

closing as there was no followup

@derberg derberg closed this as completed Oct 25, 2023
@derberg derberg removed the stale label Oct 25, 2023
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