asyncapi-archived-repos / docgen

AsyncAPI documentation generator. DEPRECATED in favour of
https://github.com/asyncapi/generator
Apache License 2.0
21 stars 11 forks source link

Fail to parse YAML content #29

Closed vodanh109 closed 6 years ago

vodanh109 commented 6 years ago

I used this module to generate HTML documents from Node, but it throws the exception:

Error: Invalid .validate call - schema must be an string or object but undefined was passed!

But I can preview my YAML content on http://editor.asyncapi.org/

Please help. Thanks a lot

vodanh109 commented 6 years ago

I can bypass this problem with loading plain text from yaml file, rather than load from js-yaml modules Thanks

fmvilas commented 6 years ago

Not sure I understand the problem. Can you please post an example to reproduce the problem?

Thanks!

vodanh109 commented 6 years ago

@fmvilas, you can try with any AsyncAPI yaml content from http://editor.asyncapi.org/ And tried with your example code:

const docs = require('asyncapi-docgen'); const asyncapi = YAML.load('./asyncapi.yaml');

try { const html = await docs.generateFullHTML(asyncapi); console.log('Done!'); console.log(html); } catch (e) { console.error(Something went wrong: ${e.message}); }

Then I just loaded plain text file and load into

await docs.generateFullHTML(asyncapi)

As I debug, the problem is because that the JSON parsed content from Yaml is like { [Object] } that is not a valid JSON data, and it cannot read schema version

fmvilas commented 6 years ago

Oh, I think I found the bug. This package doesn't have the schema for version 1.2.0. Will fix it as soon as I have time. Thanks for reporting!

fmvilas commented 6 years ago

Hey @vodanh109. I just released version 1.10.3 and it fixes the problem. Also, the editor has been updated. Thank you very much for spotting and reporting the error 🙌

fmvilas commented 6 years ago

So, apparently, this bug was actually a mix of 2 different bugs: the one I fixed above and an error in the project README examples. I just updated the examples, check it out: https://github.com/asyncapi/docgen#as-a-module-in-your-project. Thanks!