json_schema 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
data/lib/json_schema.rb CHANGED
@@ -9,23 +9,13 @@ module JsonSchema
9
9
  def self.parse(data)
10
10
  parser = Parser.new
11
11
  if schema = parser.parse(data)
12
- valid, errors = schema.expand_references
13
- if valid
14
- [schema, nil]
15
- else
16
- [nil, errors]
17
- end
12
+ [schema, nil]
18
13
  else
19
14
  [nil, parser.errors]
20
15
  end
21
16
  end
22
17
 
23
18
  def self.parse!(data)
24
- schema = Parser.new.parse!(data)
25
- schema.expand_references!
26
- schema
27
- end
28
-
29
- def self.validate(schema, data)
19
+ Parser.new.parse!(data)
30
20
  end
31
21
  end
@@ -666,7 +666,9 @@ describe JsonSchema::Validator do
666
666
  end
667
667
 
668
668
  def validate
669
- @schema = JsonSchema.parse!(schema_sample).definitions["app"]
669
+ @schema = JsonSchema.parse!(schema_sample)
670
+ @schema.expand_references!
671
+ @schema = @schema.definitions["app"]
670
672
  @validator = JsonSchema::Validator.new(@schema)
671
673
  @validator.validate(data_sample)
672
674
  end
@@ -18,16 +18,6 @@ describe JsonSchema do
18
18
  assert_includes errors.map { |e| e.message },
19
19
  %{Expected schema; value was: 4.}
20
20
  end
21
-
22
- it "returns errors on a reference expansion problem" do
23
- pointer("#/properties").merge!(
24
- "app" => { "$ref" => "#/bad-json-reference" }
25
- )
26
- schema, errors = JsonSchema.parse(schema_sample)
27
- refute schema
28
- assert_includes errors.map { |e| e.message },
29
- %{Couldn't resolve pointer "#/bad-json-reference".}
30
- end
31
21
  end
32
22
 
33
23
  describe ".parse!" do
@@ -44,17 +34,6 @@ describe JsonSchema do
44
34
  end
45
35
  assert_includes e.message, %{Expected schema; value was: 4.}
46
36
  end
47
-
48
- it "returns errors on a reference expansion problem" do
49
- pointer("#/properties").merge!(
50
- "app" => { "$ref" => "#/bad-json-reference" }
51
- )
52
- e = assert_raises(RuntimeError) do
53
- JsonSchema.parse!(schema_sample)
54
- end
55
- assert_includes e.message,
56
- %{Couldn't resolve pointer "#/bad-json-reference".}
57
- end
58
37
  end
59
38
 
60
39
  def pointer(path)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: