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:
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 22 (8 by maintainers)
Commits related to this issue
- test(schema): test loading of schemas with cyclic references schema examples provided by @AndyOGo see #185 — committed to adobe/jsonschema2md by trieloff 5 years ago
- test(schema): test README generation for cyclic schemas see #185 — committed to adobe/jsonschema2md by trieloff 5 years ago
- test(schema): remove print from README test see #185 — committed to adobe/jsonschema2md by trieloff 5 years ago
- fix(titles): more robust handling of title generation for untitled schemas see #185 — committed to adobe/jsonschema2md by trieloff 5 years ago
- fix(traversal): fix endless loop in schema traversal fixes #185 — committed to adobe/jsonschema2md by trieloff 5 years ago
- chore(release): 4.0.1 [skip ci] ## [4.0.1](https://github.com/adobe/jsonschema2md/compare/v4.0.0...v4.0.1) (2019-12-20) ### Bug Fixes * **titles:** more robust handling of title generation for unti... — committed to adobe/jsonschema2md by semantic-release-bot 5 years ago
- test(schema): test for writing cyclic schemas without an endless loop #185 — committed to adobe/jsonschema2md by trieloff 4 years ago
- fix(schema): do not recurse endlessly when writing cyclic schemas the schema writer will now load the original schema file from disk, so that only minimal changes will get made fixes #185 for good — committed to adobe/jsonschema2md by trieloff 4 years ago
- chore(release): 4.0.3 [skip ci] ## [4.0.3](https://github.com/adobe/jsonschema2md/compare/v4.0.2...v4.0.3) (2020-01-09) ### Bug Fixes * **schema:** do not recurse endlessly when writing cyclic sche... — committed to adobe/jsonschema2md by semantic-release-bot 4 years ago
Ah, then the fix should be relatively easy. We write the JSON again so that
my.schema.json
my.description.md
andmy.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.