json_schema 0.13.2 → 0.13.3
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 +11 -4
- data/test/json_schema/reference_expander_test.rb +10 -0
- 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: 2f5c2d7106b765e16464b19faf83b114eda8eef2
|
4
|
+
data.tar.gz: 8e726d2b1af63279c75ee00f6da8f6f22828caa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dec05abbc55082ef52b87d0b6dac38e4347550a619fe87b033f35b5cff5f0b1e59ad5194b4e5637f7722bda0d64f9bb341e350a9ce642fb9a82c38ee4a960d1
|
7
|
+
data.tar.gz: 076853fdad85d71c7396704c741f6f60a536f7d2f4c078e981c167671507e58827a9e5dff7567d86b54adaf8803f0b04d61082010cfa5899129523e966bfca26
|
@@ -185,10 +185,17 @@ module JsonSchema
|
|
185
185
|
resolve_uri(ref_schema, uri)
|
186
186
|
# relative
|
187
187
|
elsif uri
|
188
|
-
#
|
189
|
-
#
|
190
|
-
|
191
|
-
|
188
|
+
# Build an absolute path using the URI of the current schema.
|
189
|
+
#
|
190
|
+
# Note that this code path will never currently be hit because the
|
191
|
+
# incoming reference schema will never have a URI.
|
192
|
+
if ref_schema.uri
|
193
|
+
schema_uri = ref_schema.uri.chomp("/")
|
194
|
+
resolve_uri(ref_schema, URI.parse(schema_uri + "/" + uri.path))
|
195
|
+
else
|
196
|
+
nil
|
197
|
+
end
|
198
|
+
|
192
199
|
# just a JSON Pointer -- resolve against schema root
|
193
200
|
else
|
194
201
|
resolve_pointer(ref_schema, @schema)
|
@@ -205,6 +205,16 @@ describe JsonSchema::ReferenceExpander do
|
|
205
205
|
assert_includes error_types, :unresolved_pointer
|
206
206
|
end
|
207
207
|
|
208
|
+
it "errors on a relative URI that cannot be transformed to an absolute" do
|
209
|
+
pointer("#/properties").merge!(
|
210
|
+
"app" => { "$ref" => "relative#definitions/name" }
|
211
|
+
)
|
212
|
+
refute expand
|
213
|
+
assert_includes error_messages,
|
214
|
+
%{Couldn't resolve references: relative#definitions/name.}
|
215
|
+
assert_includes error_types, :unresolved_references
|
216
|
+
end
|
217
|
+
|
208
218
|
it "errors on a reference cycle" do
|
209
219
|
pointer("#/properties").merge!(
|
210
220
|
"app0" => { "$ref" => "#/properties/app2" },
|