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 +4 -4
- data/lib/json_schema/reference_expander.rb +15 -6
- data/test/json_schema/reference_expander_test.rb +8 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 375dc36afc9706236aa48b7cc3d014e33743c0ff
|
4
|
+
data.tar.gz: fc069f896647b5f0bde096d12f4e1b65c38ba1bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd3a3e24fb423907e5433345c552b13fc6c36e937086468c7f79ac13d1b2071603bf774f98345e8cc6a11153aedfb892a70b3cb8b28ad21209a66e81fc360731
|
7
|
+
data.tar.gz: d68d410fdcc8a349cbab6a308b8209a048eabdc72df65f7edbb7558e060cfdcdcdf3c18b9768a84d2670a61a8dc5d92833083d220269fd00ca22bad80a90a215
|
@@ -132,12 +132,21 @@ module JsonSchema
|
|
132
132
|
return
|
133
133
|
end
|
134
134
|
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
|
140
|
-
|
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"
|
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
|