asyncapi / generator

Use your AsyncAPI definition to generate literally anything. Markdown documentation, Node.js code, HTML documentation, anything!
https://asyncapi.com/docs/tools/generator
Apache License 2.0
758 stars 211 forks source link

[BUG] Docker container html template is not compatible with generator #1224

Closed DenisNovac closed 1 month ago

DenisNovac commented 3 months ago

Describe the bug.

I am using docker container https://hub.docker.com/r/asyncapi/generator , version 2.0.3

It is downloading latest (2.3.9) html-template automatically:

asyncapi-generator -i doc/input.yml -o doc/generated @asyncapi/html-template -p singleFile=true -p outFilename=out.html --force-write --debug

Warning: Ignoring extra certs from `/usr/local/share/ca-certificates/squid-ca-cert.crt`, load failed: error:02001002:system library:fopen:No such file or directory
Template installation started because you passed --install flag.
(node:43) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
Template @asyncapi/html-template successfully installed in /usr/local/lib/node_modules/@asyncapi/generator/node_modules/@asyncapi/html-template.
Version of used template is 2.3.9.
Something went wrong:
Error: This template is not compatible with the current version of the generator (2.0.3). This template is compatible with the following version range: >=1.15.0 <2.0.0.
    at isTemplateCompatible (/usr/local/lib/node_modules/@asyncapi/generator/lib/templateConfigValidator.js:57:11)
    at module.exports.validateTemplateConfig (/usr/local/lib/node_modules/@asyncapi/generator/lib/templateConfigValidator.js:30:3)
    at Generator.configureTemplateWorkflow (/usr/local/lib/node_modules/@asyncapi/generator/lib/generator.js:314:5)
    at async Generator.generate (/usr/local/lib/node_modules/@asyncapi/generator/lib/generator.js:202:5)
    at async Generator.generateFromFile (/usr/local/lib/node_modules/@asyncapi/generator/lib/generator.js:503:12)
    at async /usr/local/lib/node_modules/@asyncapi/generator/cli.js:157:9

There is no newer versions neither for html-template nor for generator.

However, when i do the same in local CLI for the same file - it works:

asyncapi config versions      

(node:29241) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
@asyncapi/cli/2.0.3 darwin-arm64 node-v22.2.0
  ├@asyncapi/avro-schema-parser/3.0.24
  ├@asyncapi/bundler/0.5.5
  ├@asyncapi/converter/1.4.21
  ├@asyncapi/diff/0.4.1
  ├@asyncapi/generator/1.17.25
  ├@asyncapi/modelina-cli/4.0.0-next.52
  ├@asyncapi/openapi-schema-parser/3.0.24
  ├@asyncapi/optimizer/1.0.2
  ├@asyncapi/parser/3.1.0
  ├@asyncapi/protobuf-schema-parser/3.2.14
  ├@asyncapi/raml-dt-schema-parser/4.0.24
  └@asyncapi/studio/0.20.2

asyncapi generate fromTemplate in.yml @asyncapi/html-template -o ./docs --force-write --debug 

(node:29070) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
┌  AsyncAPI Generator
│
Template sources taken from .../node_modules/@asyncapi/html-template.
Version of used template is 2.3.9.
...
◇  Check out your shiny new generated files at ./docs.

Expected behavior

Latest version of generator should be compatible with latest version of template.

Screenshots

This bug is CLI-based

How to Reproduce

Generate html doc using latest (2.0.3) version of docker container https://hub.docker.com/r/asyncapi/generator/tags

🥦 Browser

None

👀 Have you checked for similar open issues?

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

No, someone else can work on it

github-actions[bot] commented 3 months ago

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.

derberg commented 2 months ago

Hey there, sorry for late response - vacation and some other harder moments in life 😄

It is downloading latest (2.3.9) html-template automatically

what do you mean? docker image with generator do not contain html-template. when you run asyncapi-generator -i doc/input.yml -o doc/generated @asyncapi/html-template -p singleFile=true -p outFilename=out.html --force-write --debug the generator downloads template on the fly, with latest version as @asyncapi/html-template means latest -> have a read of https://www.asyncapi.com/docs/tools/generator/versioning

asyncapi generate fromTemplate in.yml @asyncapi/html-template -o ./docs --force-write --debug

yes, this works, cause if you look into the output of asyncapi config versions the version of generator in the CLI is older than v2. html-template is not yet on v2. We need to get https://github.com/asyncapi/cli/issues/1388 done first.

I definitely discourage you from using the docker image provided by generator, with Generator CLI because we will anyway set it to deprecation -> https://github.com/asyncapi/generator/issues/1212. You probably noticed that in generator docs we do not even talk about Generator CLI anymore

does that help?

DenisNovac commented 1 month ago

Thank you for answering!

html-template is not yet on v2

I guess, this explains my problem. Long story short - our CI upgraded the container to v2 and started to fail at some point. I just downgraded it and now it works. Maybe next time we will update it when v2 is supported.