html-template icon indicating copy to clipboard operation
html-template copied to clipboard

[BUG] Missing CSS/JS when generating without `singleFile`

Open Shurtu-gal opened this issue 1 year ago • 19 comments

Describe the bug.

When generating docs with @asyncapi/html-template version 3.3.0+, the generated index.html references CSS and JS files, but they are not created in the output folder when singleFile is not used.

With 3.2.0, both singleFile=true and singleFile=false modes worked correctly. Starting with 3.3.0, only singleFile=true works.

[!TIP] I suspect the issue is with the new conditional generation added.

Expected behavior

  • If singleFile=true: generate one standalone HTML file with bundled CSS/JS (works fine in 3.3.1 also).
  • If singleFile=false (or not passed): generate index.html + referenced css/ and js/ assets (broken in 3.3.0+).

Screenshots

Image

How to Reproduce

  1. Run: ./bin/run generate fromTemplate asyncapi.yaml @asyncapi/html-template -o ../docs --use-new-generator --force-write

  2. Example spec (simplified):

asyncapi: 3.0.0
info:
  title: Account Service
  version: 1.0.0
channels:
  userSignedup:
    address: user/signedup
    messages:
      UserSignedUp:
        $ref: '#/components/messages/UserSignedUp'
components:
  messages:
    UserSignedUp:
      payload:
        type: object
        properties:
          email:
            type: string
  1. Open the generated index.html in the browser.

  2. Notice that it references CSS/JS files, but none are generated.

🖥️ Device Information [optional]

  • Operating System (OS):
  • Browser:
  • Browser Version:

👀 Have you checked for similar open issues?

  • [x] I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

None

Shurtu-gal avatar Sep 18 '25 14:09 Shurtu-gal

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.

github-actions[bot] avatar Sep 18 '25 14:09 github-actions[bot]

I have the same issue.

Versions of asyncapi/html-template/generator are bellow:

$ asyncapi --version
@asyncapi/cli/3.5.2 linux-x64 node-v24.7.0
$ npm list -g @asyncapi/html-template
/home/georgii/.nvm/versions/node/v24.7.0/lib
└─┬ @asyncapi/[email protected]
  └─┬ generator-v2@npm:@asyncapi/[email protected]
    └── @asyncapi/[email protected]

georgyturevich avatar Sep 22 '25 14:09 georgyturevich

is it still valid?? I would like to work on this @Shurtu-gal

batchu5 avatar Oct 27 '25 18:10 batchu5

I believe so.

Shurtu-gal avatar Oct 28 '25 12:10 Shurtu-gal

okay I'm working on it

batchu5 avatar Oct 28 '25 15:10 batchu5

Image

I think it is working now not an bug anymore

batchu5 avatar Oct 28 '25 17:10 batchu5

I think it is working now not an bug anymore

Please try with version 3.3.0

Shurtu-gal avatar Nov 06 '25 19:11 Shurtu-gal

@Shurtu-gal I tried using html-template version 3.3.0. The CSS and JS files are generated, but index.html isn’t referencing them. It only contains inline script and CSS instead of linking to the external files.

but you said, When generating docs with @asyncapi/html-template version 3.3.0+, the generated index.html references CSS and JS files, but they are not created in the output folder when singleFile is not used.

the command I used : asyncapi generate fromTemplate asyncapi.yaml @asyncapi/[email protected] --use-new-generator -o output -p singleFile=false

Am i doing something wrong?

batchu5 avatar Nov 15 '25 06:11 batchu5

No that might also be an issue.

Shurtu-gal avatar Nov 18 '25 14:11 Shurtu-gal

@Shurtu-gal I have checked with version 3.3.0 by cloning the repo and switching to branch v3.3.1

this is package.json Image

example.yml is the code you provided and generated the output using command npm run test:example

I'm not getting any error

Image

batchu5 avatar Nov 18 '25 19:11 batchu5

Yeah, test won't give the error. To reproduce it, need to run with generator.

Shurtu-gal avatar Nov 20 '25 16:11 Shurtu-gal

checked with latest 3.3.1

Problem might be in https://github.com/asyncapi/generator/blob/master/apps/generator/lib/templates/config/loader.js#L47. Tests should be checked for loadDefaultValues.

in html-template config https://github.com/asyncapi/html-template/blob/master/package.json#L90-L93 singleFile default is false. So if you do not pass this parameter, false value should be injected with context into generation process.

This false default value is critical for another setting (conditional generation): https://github.com/asyncapi/html-template/blob/master/package.json#L63-L75 which means that required css and js folders will be rendered in output only fi singleFile is set to false.

asyncapi generate fromTemplate test/spec/asyncapi_v3.yml ./ -o dupa --use-new-generator --force-write -p singleFile=false works as expected, false goes through, so directories are there. Of course flah singleFile=true works as well.


Problem is that during generation in case like asyncapi generate fromTemplate test/spec/asyncapi_v3.yml ./ -o dupa --use-new-generator --force-write the template gets singleFile as undefined (doesn't get it at all). I can only see the following defaults

{
  "outFilename": "index.html",
  "pdfTimeout": 30000
}

So there is for sure a bug in generator, it is not handling default values set to false

derberg avatar Nov 24 '25 16:11 derberg

hey @Shurtu-gal @derberg I think there might be a small mismatch in how the command is being run... Right now, the generator expects singleFile as a string, so the CLI usage should be:

-p singleFile="false"

not:

-p singleFile=false

That is also consistent with how .ageneratorrc is defined in the generator repo, for example here we use:

enum: ["false"] #and many more places..

https://github.com/asyncapi/generator/blob/master/apps/generator/test/test-templates/react-template/.ageneratorrc#L33

I’ve already opened a PR to fix loadDefaultValues so that default values like false are correctly applied. After that fix, the default singleFile: false works as expected, but:

false==="false" // output will always be false

so -p singleFile=false (boolean-like) won’t match the const: "false" in the template config.

Do you expect both forms to work:

-p singleFile=false      # boolean-like
-p singleFile="false"    # string

or is the intended contract that only the string "false" is supported via CLI?

If the goal is for both to work, the solution is ready!! just waiting for your call!

lightning-sagar avatar Nov 26 '25 17:11 lightning-sagar

i think i got the solution for it, whether it is string or boolean. But I am still waiting for you guys to responed.. Based on your feedback, i will create the PR!! or whatever you guys recommend...🫡

Edit: Since there’s already a PR open, I’ll help guide her toward the correct path instead of opening a duplicate

lightning-sagar avatar Nov 26 '25 18:11 lightning-sagar

Hi, I’m new to the project and would like to work on this issue. Is it still open and okay for me to take it?

Vaibhav-Adarsh avatar Dec 26 '25 05:12 Vaibhav-Adarsh

Hi, I'm new here to this project and would like to contribute to fix this issue. Is it still open to work on ?

sabyasachi008 avatar Jan 05 '26 06:01 sabyasachi008

Hello @derberg is this issue open? Can I work on it?

aaryab27 avatar Jan 09 '26 12:01 aaryab27

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

The release is available on:

Your semantic-release bot :package::rocket:

asyncapi-bot avatar Jan 23 '26 08:01 asyncapi-bot

it is fixed but requires people to use latest generator @asyncapi/[email protected] so if anyone wanna use the fix, need to make sure lates generator is bumped in https://github.com/asyncapi/cli

derberg avatar Jan 23 '26 08:01 derberg