hoxworth/json-schema — pull request #127 by mpalmer (2014-09-21 03:31:12+00:00)
Title: Make intra-doc refs work when validating with :fragment

Here's a weird corner-case for you: when calling JSON::Validator.validate
and using the :fragment option, any references to other parts of the same
schema would fail. Why? Because the handling of :fragment involved
creating a *new* schema, with a new URI, with a subset of the original
schema. Internal refs (as handled by JSON::Schema::RefAttribute) would try
to resolve the ref within this sub-schema, and go *fwackoom* because the
structure of the sub-schema wouldn't have the right path in it.

I've adjusted the code for schema_from_fragment to not call
initialize_schema (and hence not create those new sub-schemas), and instead
just create a new JSON::Schema object (which, according to the comments, is
the only reason that initialize_schema was being called). This causes no
new schemas to be created, and RefAttribute can go looking up its ref in the
right place.