Closed okitan closed 8 years ago
Here is the brief POC code.
json = <<_JSON_ { "id": "http://example.com/poc.json", "$schema": "http://json-schema.org/draft-04/hyper-schema#", "definitions": { "self": { "$ref": "#" }, "synonym": { "$ref": "#/definitions/self" } }, "properties": { "id": { "type": "string" } } } _JSON_ schema = JsonSchema::Parser.new.parse!(JSON.parse(json)) schema.expand_references #=> SystemStackError
I found #/definitions/synonym is treated as original, and schema_children of it includes #/definitions/synonym. It means schema.parent returns schema itself, and it cause infinite loop and stack level too deep error when schema.parent is called against #/definitions/synonym. (See: https://github.com/brandur/json_schema/blob/master/lib/json_schema/reference_expander.rb#L100-L104)
#/definitions/synonym
schema_children
schema.parent
I also found # were not treated as original. This is also wired.
#
I tried to fix "original problem", but I can't....
Here is the brief POC code.
I found
#/definitions/synonym
is treated as original, andschema_children
of it includes#/definitions/synonym
. It meansschema.parent
returns schema itself, and it cause infinite loop and stack level too deep error whenschema.parent
is called against#/definitions/synonym
. (See: https://github.com/brandur/json_schema/blob/master/lib/json_schema/reference_expander.rb#L100-L104)I also found
#
were not treated as original. This is also wired.I tried to fix "original problem", but I can't....