Fix infinite recursion with recursive schemas #314
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The following schema demonstrates the issue:
{ "$schema": "http://json-schema.org/draft-07/schema#", "$ref": "#/$defs/Json.Value", "$defs": { "Json.Value": { "anyOf": [ { "$ref": "#/$defs/Json.Primitive" }, { "$ref": "#/$defs/Json.Array" }, { "$ref": "#/$defs/Json.Record" } ] }, "Json.Primitive": { "anyOf": [ { "type": "boolean" }, { "type": "number" }, { "type": "string" }, { "type": "null" } ] }, "Json.Array": { "type": "array", "items": { "$ref": "#/$defs/Json.Value" } }, "Json.Record": { "type": "object", "required": [], "properties": {}, "additionalProperties": { "$ref": "#/$defs/Json.Value" } } } }Save that to
input.json, and run:Before the proposed changes, this would lead to a
RecursionError: maximum recursion depth exceeded. With the changes in place, the output.html generates as desired.I also tested against the schema posted in #246, and it resolves the issue there, too.
The proposed fix was mainly the result of the analysis of an LLM, and didn't come from a place of personal understanding of the code. Caution advised while reviewing.