json-schema_builder 0.6.0 → 0.6.1

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: e13b97322fe070943bcaa063cbb11661fd0b576d
4
- data.tar.gz: eb0dfeccc78fc5af31b50889af7473a9eeedf566
3
+ metadata.gz: 6b2db2f9c08d0d7f20bc942b2b8f80692dcb6606
4
+ data.tar.gz: 4aaa1d7fc0179c8c8f8d8dc5b3e20165f27b919b
5
5
  SHA512:
6
- metadata.gz: 9db0f2942aa747cff7b9f94d41fb363ec03f9262d30ad29b313582787fb6aa7eed1168165bd25ebf07bfad0fff83cb73c22ca60ec7e52c9766c0388ddc57a8cb
7
- data.tar.gz: 4bea5f690c51c8b3caad56dff0818d72cd20282baf192334e6562597424d220021511ed15794837fb6dabef5128b72822ed657efb6a235852ddd45b85510934a
6
+ metadata.gz: 3989f1a40c2f42e11540011f74f6edbfa23595868dea68b985c90f349178607f6ebe1f1a1526e156cf5c8a3de3aa000a7858a67793b434cb1b4518e251bf484a
7
+ data.tar.gz: 4ab4fe02482693de7c9628e29f80258c315ddc37a886ac70489dc2e8dfe355c9bec275286b02c015a2fc8d6a49cd6e3aed20be903288f1ae5112168058cc3912
@@ -18,6 +18,7 @@ module JSON
18
18
  opts = args.extract_options!
19
19
  name = args.shift
20
20
  nullable = opts.delete :null
21
+ any_ofs = opts.delete :any_of
21
22
 
22
23
  entity name do
23
24
  list = [
@@ -29,7 +30,8 @@ module JSON
29
30
  }
30
31
  ]
31
32
 
32
- list << null if nullable
33
+ list |= any_ofs if any_ofs
34
+ list |= [null] if nullable && list.none? { |item| item.is_a?(Null) }
33
35
  any_of list
34
36
  end
35
37
  end
@@ -1,5 +1,5 @@
1
1
  module JSON
2
2
  module SchemaBuilder
3
- VERSION = '0.6.0'
3
+ VERSION = '0.6.1'
4
4
  end
5
5
  end
@@ -26,6 +26,35 @@ RSpec.describe Examples::MixedAnyOfs, type: :integration do
26
26
  { type: "null" }
27
27
  ]
28
28
  },
29
+ mixed_type: {
30
+ anyOf: [
31
+ {
32
+ type: "object",
33
+ properties: {
34
+ property: {
35
+ type: "string"
36
+ }
37
+ }
38
+ },
39
+ {
40
+ type: "array",
41
+ items: {
42
+ type: "object",
43
+ properties: {
44
+ property: {
45
+ type: "string"
46
+ }
47
+ }
48
+ }
49
+ },
50
+ {
51
+ type: "string",
52
+ },
53
+ {
54
+ type: "null"
55
+ }
56
+ ]
57
+ },
29
58
  flexible: {
30
59
  anyOf: [
31
60
  { type: "string", minLength: 100 },
@@ -10,6 +10,10 @@ module Examples
10
10
  string :test
11
11
  end
12
12
 
13
+ object_or_array :mixed_type, any_of: [string, null], null: true do
14
+ string :property
15
+ end
16
+
13
17
  entity :flexible, any_of: [string(min_length: 100), empty_string, integer], null: true do
14
18
  any_of [
15
19
  an_object(self),
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json-schema_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Parrish
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-25 00:00:00.000000000 Z
11
+ date: 2018-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler