json_schema 0.20.2 → 0.20.3

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
  SHA256:
3
- metadata.gz: f8995d131af07bfdde3422f2a9cac2a8aaaab975c98692bb944bb8430847cda1
4
- data.tar.gz: 893dfed770a20c6e7e66b2a8c0bd8a3defae02a7f2413f839a23df45344028bc
3
+ metadata.gz: 45216e42386e80c6e481d45fafb3bcecad1c55cde5137efb455bb45261e87424
4
+ data.tar.gz: 8764080e6a1c38b519110a8001b53ebda5864e7b16cdf418b272459542f60e1f
5
5
  SHA512:
6
- metadata.gz: 126055feefc345b2eb5df31af7e0536569d1054ed2ba14d0976ad441078bf577cbaa320b8cbfc1de5da50018ba2bb6463ad60216a9bfbda0622677cc865aa62f
7
- data.tar.gz: 03b6f5215269dbd62323fec83204316bc3ab8b143185ec1a4bfe6be67a79fa88406d2ef05ce63f372525ceb411a9e7e3878470b6303702b3b1cbeca2aa2d19d0
6
+ metadata.gz: 0f43b198fc8050550fb78d3a96ad14dff765fdcce80b5ae73ce080e6fb13600697658cf3b9d2b73e1ed9adc0d40cedfb890047696778dc5e3770dead5889e666
7
+ data.tar.gz: 6f30c6b07f81396b3f7366fd30186b83ddbf1ef474e375838c77df5a635b96bc2ac4dc4bf2036789a235f19efa3bc22ac76c246d31db9a697b8235790f045c4b
@@ -117,14 +117,15 @@ module JsonSchema
117
117
  # schema as the reference schema.
118
118
  next if ref_schema == subschema
119
119
 
120
- subref = subschema.reference
121
- # the subschema's ref is local to the file that the
122
- # subschema is in; however since there's no URI
123
- # the 'resolve_pointer' method would try to look it up
124
- # within @schema. So: manually reconstruct the reference to
125
- # use the URI of the parent ref.
126
- subschema.reference = JsonReference::Reference.new("#{ref.uri}#{subref.pointer}")
127
- dereference(subschema, ref_stack + [subref])
120
+ if !subschema.reference.uri
121
+ # the subschema's ref is local to the file that the
122
+ # subschema is in; however since there's no URI
123
+ # the 'resolve_pointer' method would try to look it up
124
+ # within @schema. So: manually reconstruct the reference to
125
+ # use the URI of the parent ref.
126
+ subschema.reference = JsonReference::Reference.new("#{ref.uri}#{subschema.reference.pointer}")
127
+ end
128
+ dereference(subschema, ref_stack)
128
129
  end
129
130
  end
130
131
 
@@ -265,7 +265,62 @@ describe JsonSchema::ReferenceExpander do
265
265
  assert schema.expanded?
266
266
  end
267
267
 
268
- it "expands a schema with a reference to an external schema with a nested property reference" do
268
+ it "expands a schema with a reference to an external schema with a nested external property reference" do
269
+ sample1 = {
270
+ "$schema" => "http://json-schema.org/draft-04/hyper-schema",
271
+ "type" => "object",
272
+ "properties" => {
273
+ "foo" => {
274
+ "$ref" => "http://json-schema.org/b.json#/definitions/bar"
275
+ }
276
+ }
277
+ }
278
+ schema1 = JsonSchema::Parser.new.parse!(sample1)
279
+ schema1.uri = "http://json-schema.org/a.json"
280
+
281
+ sample2 = {
282
+ "$schema" => "http://json-schema.org/draft-04/hyper-schema",
283
+ "type" => "object",
284
+ "definitions" => {
285
+ "bar" => {
286
+ "type" => "object",
287
+ "properties" => {
288
+ "omg" => {
289
+ "$ref" => "http://json-schema.org/c.json#/definitions/baz"
290
+ }
291
+ }
292
+ }
293
+ }
294
+ }
295
+ schema2 = JsonSchema::Parser.new.parse!(sample2)
296
+ schema2.uri = "http://json-schema.org/b.json"
297
+
298
+ sample3 = {
299
+ "$schema" => "http://json-schema.org/draft-04/hyper-schema",
300
+ "type" => "object",
301
+ "definitions" => {
302
+ "baz" => {
303
+ "type" => "string",
304
+ "maxLength" => 3
305
+ }
306
+ }
307
+ }
308
+ schema3 = JsonSchema::Parser.new.parse!(sample3)
309
+ schema3.uri = "http://json-schema.org/c.json"
310
+
311
+ # Initialize a store and add our schema to it.
312
+ store = JsonSchema::DocumentStore.new
313
+ store.add_schema(schema1)
314
+ store.add_schema(schema2)
315
+ store.add_schema(schema3)
316
+
317
+ expander = JsonSchema::ReferenceExpander.new
318
+ expander.expand!(schema1, store: store)
319
+
320
+ assert_equal 3, schema1.properties["foo"].properties["omg"].max_length
321
+ end
322
+
323
+ it "expands a schema with a reference to an external schema with a nested local property reference" do
269
324
  sample1 = {
270
325
  "$schema" => "http://json-schema.org/draft-04/hyper-schema",
271
326
  "type" => "object",
metadata CHANGED
@@ -1,113 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.2
4
+ version: 0.20.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-20 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ecma-re-validator
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.1'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.1'
27
- - !ruby/object:Gem::Dependency
28
- name: minitest
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '5.3'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '5.3'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '10.3'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '10.3'
55
- - !ruby/object:Gem::Dependency
56
- name: byebug
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: pry
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: pry-byebug
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: simplecov
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
11
+ date: 2019-02-23 00:00:00.000000000 Z
12
+ dependencies: []
111
13
  description:
112
14
  email:
113
15
  - brandur@mutelight.org