Skip to content

Commit

Permalink
Rearrange nested schema expansion
Browse files Browse the repository at this point in the history
This is simply to make it easier to see the change in the next commit,
which addresses an edge case in the nested expansion.
  • Loading branch information
Katrina Owen committed Mar 1, 2019
1 parent c141555 commit aedee73
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/json_schema/reference_expander.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,23 @@ def dereference(ref_schema, ref_stack)
# references.
if ref.uri
schema_children(new_schema) do |subschema|
next if subschema.expanded?
next unless subschema.reference

# Don't bother if the subschema points to the same
# schema as the reference schema.
next if ref_schema == subschema

if !subschema.reference.uri
# the subschema's ref is local to the file that the
# subschema is in; however since there's no URI
# the 'resolve_pointer' method would try to look it up
# within @schema. So: manually reconstruct the reference to
# use the URI of the parent ref.
subschema.reference = JsonReference::Reference.new("#{ref.uri}#{subschema.reference.pointer}")
next if subschema.expanded?

if subschema.reference
if !subschema.reference.uri
# the subschema's ref is local to the file that the
# subschema is in; however since there's no URI
# the 'resolve_pointer' method would try to look it up
# within @schema. So: manually reconstruct the reference to
# use the URI of the parent ref.
subschema.reference = JsonReference::Reference.new("#{ref.uri}#{subschema.reference.pointer}")
end
end

dereference(subschema, ref_stack)
end
end
Expand Down

0 comments on commit aedee73

Please sign in to comment.