json_schema 0.13.4 → 0.13.5

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: f66751bcac58d7b1dc4b2cfbe37c0b9c9d588fa6
4
- data.tar.gz: eb658403b9f8c3ad98f1830be57610e398ad3944
3
+ metadata.gz: 714bee88016f66e9aa064a65cbdcac3da544345c
4
+ data.tar.gz: ac1aee2ff1cfc8fdfc8733782eba71485d473588
5
5
  SHA512:
6
- metadata.gz: 184db105da05420130fb953b4cd90c41282f0f6963f03a80823baff5a79216d247502113153276ce7b75cb41b2a2a5a1262e4f68ce26cd67d00f041aca5e4fba
7
- data.tar.gz: 394c95fb5e5781ae828556758629a873666b0ec36f9e3ed15163d06fc8610713227a29a4a652702da0c3560cdf684624fd8b01beb483d4de207ed62ad5b98588
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
- @uri = URI.parse(schema.uri)
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
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-04 00:00:00.000000000 Z
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