json_schema 0.13.4 → 0.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/json_schema/reference_expander.rb +8 -1
- data/test/json_schema/reference_expander_test.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 714bee88016f66e9aa064a65cbdcac3da544345c
|
4
|
+
data.tar.gz: ac1aee2ff1cfc8fdfc8733782eba71485d473588
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c71070be974462466e3717a15d944e9c950a600ab0f3665fac62b5b6261acaa0ab27acbf75bdf53a998a2deb601e5bdb683784ff68627cef1e05afefe9c4c313
|
7
|
+
data.tar.gz: cc0418ca51ae31501d1480521d2d9f5ef91987f9ef4bf879c06729a23a29eeef20a52dc6b1c5fa81f403d76d5b799632687dd37907d2724b0de8f0daf69303f2
|
@@ -11,7 +11,14 @@ module JsonSchema
|
|
11
11
|
@schema = schema
|
12
12
|
@schema_paths = {}
|
13
13
|
@store = options[:store] || DocumentStore.new
|
14
|
-
|
14
|
+
|
15
|
+
# If the given JSON schema is _just_ a JSON reference and nothing else,
|
16
|
+
# short circuit the whole expansion process and return the result.
|
17
|
+
if schema.reference && !schema.expanded?
|
18
|
+
return dereference(schema, [])
|
19
|
+
end
|
20
|
+
|
21
|
+
@uri = URI.parse(schema.uri)
|
15
22
|
|
16
23
|
@store.each do |uri, store_schema|
|
17
24
|
build_schema_paths(uri, store_schema)
|
@@ -244,6 +244,27 @@ describe JsonSchema::ReferenceExpander do
|
|
244
244
|
end
|
245
245
|
end
|
246
246
|
|
247
|
+
it "expands a schema that is just a reference" do
|
248
|
+
# First initialize another schema. Give it a fully qualified URI so that we
|
249
|
+
# can reference it across schemas.
|
250
|
+
schema = JsonSchema::Parser.new.parse!(schema_sample)
|
251
|
+
schema.uri = "http://json-schema.org/test"
|
252
|
+
|
253
|
+
# Initialize a store and add our schema to it.
|
254
|
+
store = JsonSchema::DocumentStore.new
|
255
|
+
store.add_schema(schema)
|
256
|
+
|
257
|
+
# Have the parser parse _just_ a reference. It should resolve to a
|
258
|
+
# subschema in the schema that we initialized above.
|
259
|
+
schema = JsonSchema::Parser.new.parse!(
|
260
|
+
{ "$ref" => "http://json-schema.org/test#/definitions/app" }
|
261
|
+
)
|
262
|
+
expander = JsonSchema::ReferenceExpander.new
|
263
|
+
expander.expand!(schema, store: store)
|
264
|
+
|
265
|
+
assert schema.expanded?
|
266
|
+
end
|
267
|
+
|
247
268
|
def error_messages
|
248
269
|
@expander.errors.map { |e| e.message }
|
249
270
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ecma-re-validator
|