Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Fail to parse YAML content #29

Closed
vodanh109 opened this issue Jul 11, 2018 · 6 comments
Closed

Fail to parse YAML content #29

vodanh109 opened this issue Jul 11, 2018 · 6 comments

Comments

@vodanh109
Copy link

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
Copy link
Author

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

@fmvilas
Copy link
Contributor

fmvilas commented Jul 12, 2018

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

Thanks!

@vodanh109
Copy link
Author

vodanh109 commented Jul 16, 2018

@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
Copy link
Contributor

fmvilas commented Jul 16, 2018

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
Copy link
Contributor

fmvilas commented Jul 21, 2018

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
Copy link
Contributor

fmvilas commented Aug 18, 2018

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants