Skip to content

Commit

Permalink
Standard bugfixes after a version push (sigh). An error is now thrown…
Browse files Browse the repository at this point in the history
… when a referenced schema cannot be loaded, and the new ':list' object now properly loads the internal schema and builds out references.
  • Loading branch information
hoxworth committed Dec 14, 2010
1 parent 9be86fa commit d28ec0e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/json-schema/validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def validate_ref(current_schema, data, fragments)
# Grab the parent schema from the schema list
schema_key = temp_uri.to_s.split("#")[0]
ref_schema = Validator.schemas[schema_key]

if ref_schema
# Perform fragment resolution to retrieve the appropriate level for the schema
target_schema = ref_schema.schema
Expand All @@ -485,6 +485,8 @@ def validate_ref(current_schema, data, fragments)
# We have the schema finally, build it and validate!
schema = JSON::Schema.new(target_schema,temp_uri)
validate_schema(schema, data, fragments)
else
raise ValidationError.new("The referenced schema '#{temp_uri.to_s}' cannot be found", fragments, current_schema)
end
end

Expand Down Expand Up @@ -525,8 +527,7 @@ def load_ref_schema(parent_schema,ref)


# Build all schemas with IDs, mapping out the namespace
def build_schemas(parent_schema)

def build_schemas(parent_schema)
# Check for schemas in union types
["type", "disallow"].each do |key|
if parent_schema.schema[key] && parent_schema.schema[key].is_a?(Array)
Expand Down

0 comments on commit d28ec0e

Please sign in to comment.