brandur / json_schema

A JSON Schema V4 and Hyperschema V4 parser and validator.
MIT License
230 stars 45 forks source link

When expanding references, evaluate JSON pointers in current schema #75

Closed brandur closed 7 years ago

brandur commented 7 years ago

Up until now, if a JSON reference happened to point over to another schema, we'd resolve that pointer according to the schema's raw data and not the parsed schema itself. After resolving the pointer, we'd parse whatever JSON data that it had pointed to.

This mostly worked, but wasn't very efficient, and in a case where we pointed to data that was a JSON reference itself, that reference would come back parsed but not expanded.

This patch augments the JSON pointer evaluator so that it can resolve across either raw JSON data or an instance of JsonSchema::Schema. We then use this to our advantage in the JSON reference expander by just re-using the schema that we're already expanding.

brandur commented 7 years ago

Released as 0.14.0.