json_schema 0.12.0 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ad0b2694247ed71b5163e4cb0e13799bc976c74
4
- data.tar.gz: 8cb84d6e25a4badfd97a8b59dd81b75cb75bb88c
3
+ metadata.gz: 375dc36afc9706236aa48b7cc3d014e33743c0ff
4
+ data.tar.gz: fc069f896647b5f0bde096d12f4e1b65c38ba1bd
5
5
  SHA512:
6
- metadata.gz: 7db5975866312faf10720b8cc1e188f3fc8b12c2d06507dd3536411870e90ea9524f437400730071aff6687b38cc5616849ab47b22e257f60fee8ec7643e942c
7
- data.tar.gz: 05d7b10c66a92eb00d6e3baafe1d37d5a471e7e25e0554b46a0922338703abc37523c55e36671b8e7b5517e3aa59654a591ba8cb621c3824527f60a11aaedc41
6
+ metadata.gz: bd3a3e24fb423907e5433345c552b13fc6c36e937086468c7f79ac13d1b2071603bf774f98345e8cc6a11153aedfb892a70b3cb8b28ad21209a66e81fc360731
7
+ data.tar.gz: d68d410fdcc8a349cbab6a308b8209a048eabdc72df65f7edbb7558e060cfdcdcdf3c18b9768a84d2670a61a8dc5d92833083d220269fd00ca22bad80a90a215
@@ -132,12 +132,21 @@ module JsonSchema
132
132
  return
133
133
  end
134
134
 
135
- # Parse a new schema and use the same parent node. Basically this is
136
- # exclusively for the case of a reference that needs to be
137
- # de-referenced again to be resolved.
138
- # TODO: Fix to never parse.
139
- new_schema = Parser.new.parse(data, ref_schema.parent)
140
- build_schema_paths(ref.uri, resolved_schema)
135
+ # Try to aggressively detect a circular dependency in case of another
136
+ # reference. See:
137
+ #
138
+ # https://github.com/brandur/json_schema/issues/50
139
+ #
140
+ if new_schema = lookup_pointer(ref.uri, data["$ref"])
141
+ new_schema.clones << ref_schema
142
+ else
143
+ # Parse a new schema and use the same parent node. Basically this is
144
+ # exclusively for the case of a reference that needs to be
145
+ # de-referenced again to be resolved.
146
+ # TODO: Fix to never parse.
147
+ new_schema = Parser.new.parse(data, ref_schema.parent)
148
+ build_schema_paths(ref.uri, resolved_schema)
149
+ end
141
150
  else
142
151
  # insert a clone record so that the expander knows to expand it when
143
152
  # the schema traversal is finished
@@ -162,7 +162,8 @@ describe JsonSchema::ReferenceExpander do
162
162
  # they've been nested
163
163
  it "builds appropriate JSON Pointers for circular dependencies" do
164
164
  pointer("#/properties").merge!(
165
- "app" => { "$ref" => "#" }
165
+ "app" => { "$ref" => "#" },
166
+ "app1" => { "$ref" => "#/properties/app"}
166
167
  )
167
168
  expand
168
169
 
@@ -173,6 +174,12 @@ describe JsonSchema::ReferenceExpander do
173
174
  # but diving deeper results in the same pointer again
174
175
  schema = schema.properties["app"]
175
176
  assert_equal "#/properties/app", schema.pointer
177
+
178
+ schema = @schema.properties["app1"]
179
+ assert_equal "#/properties/app1", schema.pointer
180
+
181
+ schema = schema.properties["app1"]
182
+ assert_equal "#/properties/app1", schema.pointer
176
183
  end
177
184
 
178
185
  it "errors on a JSON Pointer that can't be resolved" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandur