jsonschema2md: Version 4 cyclic refs freezes without any error

What did you do

I just upgraded to version 4 from verison 3 and tried to generate md files by running my NPM docs script:

npm run docs
# which executs: jsonschema2md -o docs/ -x docs/ -d schemas/ -e json

What did you expect to happen

All markdown files to be generated

What happened

The CLI programm freezes without any error. Last log is:

loading schemas

What’s your environment

  • Operating System: macOS Catalina 10.15.2 (19C57)
  • node.js version: v10.15.0

Do you have example files:

https://github.com/axa-ch/cyclic-schemas-test

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 22 (8 by maintainers)

Commits related to this issue

Most upvoted comments

also note: the error only occurs when writing the json again (@trieloff what is the point of this, actually?). and not when writing the markdown.

Ah, then the fix should be relatively easy. We write the JSON again so that my.schema.json my.description.md and my.1.example.json get merged into one document. The separate documents are easier to author, but the merged document is easier to consume by other tooling.

@AndyOGo a quick workaround for you might be to disable the JSON output.

@tripodsan I think our error is that the writeJsonSync function tries to serialize the proxied JSON Schema, which is recursive and gets caught up in a loop. We can circumvent this by merging the description and examples into the original (non-proxied and non-recursive) JSON and then just writing this.


The markdown processing doesn’t get caught in an endless loop, because we generate one output for each schema, and the schema identity is independent from the depth in the recursive tree.

@AndyOGo the next release should have a fix. At least a fix that works with the example you’ve shared.

@trieloff here you go 😃 https://github.com/axa-ch/cyclic-schemas-test

Please let me know if you need any more data

Could you try to create a minimal example, just to validate the assumption that it has something to do with the recursion? e.g. three schemas that form a cycle.