dry-schema 1.9.0 → 1.9.3
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/CHANGELOG.md +39 -1
- data/README.md +1 -1
- data/dry-schema.gemspec +1 -1
- data/lib/dry/schema/extensions/json_schema/schema_compiler.rb +14 -2
- data/lib/dry/schema/message/or/multi_path.rb +73 -13
- data/lib/dry/schema/message/or.rb +2 -2
- data/lib/dry/schema/messages/namespaced.rb +5 -0
- data/lib/dry/schema/messages/yaml.rb +2 -2
- data/lib/dry/schema/processor.rb +1 -1
- data/lib/dry/schema/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2dead9a036c0d9322c68b50938417ebe12a4b62ed2f99a8ae6d4f49f894dabd
|
4
|
+
data.tar.gz: ac3b386e3266e8498aa62549cddfbaece9414281beee5710c1930b062eaacde8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0831055ac93da2898c55b6194703e87bda1c27040ac23965c5f261c2e59387888f679b9dcd967a4a0665cef220b7c97db823670067267b34b40ed09a3c315b81'
|
7
|
+
data.tar.gz: d82ee10469742e83ee412ebe6c06593a86c44c1e0f01fd29067700d9a37ecc461dc3e4ad6e2a09bfe4694d1e95b6c28132810bf243d27338257f66e0c50cc98e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,43 @@
|
|
1
1
|
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
|
2
2
|
|
3
|
+
## 1.9.3 2022-06-23
|
4
|
+
|
5
|
+
|
6
|
+
### Added
|
7
|
+
|
8
|
+
- Support `anyOf` composition in JSON schema output (@robhanlon22)
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- Allow composition of multiple ors (issue #307 fixed via #409) (@robhanlon22)
|
13
|
+
|
14
|
+
|
15
|
+
[Compare v1.9.2...v1.9.3](https://github.com/dry-rb/dry-schema/compare/v1.9.2...v1.9.3)
|
16
|
+
|
17
|
+
## 1.9.2 2022-05-28
|
18
|
+
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
|
22
|
+
- Fix loose JSON schemas for nested hashes (via #401) (@tomdalling)
|
23
|
+
- Correct spelling error 'mininum' to 'minimum' in json-schema extension (via #404) (@svenanderzen)
|
24
|
+
|
25
|
+
### Changed
|
26
|
+
|
27
|
+
- [performance] YAML message backend allocates less strings (via #399) (@casperisfine)
|
28
|
+
|
29
|
+
[Compare v1.9.1...v1.9.2](https://github.com/dry-rb/dry-schema/compare/v1.9.1...v1.9.2)
|
30
|
+
|
31
|
+
## 1.9.1 2022-02-17
|
32
|
+
|
33
|
+
|
34
|
+
### Fixed
|
35
|
+
|
36
|
+
- Namespaced messages no longer crashes in certain scenarios (see dry-rb/dry-validation#692 fixed via #398) (@krekoten)
|
37
|
+
|
38
|
+
|
39
|
+
[Compare v1.9.0...v1.9.1](https://github.com/dry-rb/dry-schema/compare/v1.9.0...v1.9.1)
|
40
|
+
|
3
41
|
## 1.9.0 2022-02-15
|
4
42
|
|
5
43
|
|
@@ -136,7 +174,7 @@ This release ships with a bunch of internal refactorings that should improve per
|
|
136
174
|
- Key validation works correctly with a non-nested maybe hashes (issue #311 fixed via #312) (@svobom57)
|
137
175
|
|
138
176
|
|
139
|
-
[Compare v1.5.3...
|
177
|
+
[Compare v1.5.3...main](https://github.com/dry-rb/dry-schema/compare/v1.5.3...main)
|
140
178
|
|
141
179
|
## 1.5.3 2020-08-21
|
142
180
|
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
[][actions]
|
12
12
|
[][codacy]
|
13
13
|
[][codacy]
|
14
|
-
[][inchpages]
|
15
15
|
|
16
16
|
## Links
|
17
17
|
|
data/dry-schema.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
29
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
30
|
-
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-schema/blob/
|
30
|
+
spec.metadata["changelog_uri"] = "https://github.com/dry-rb/dry-schema/blob/main/CHANGELOG.md"
|
31
31
|
spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-schema"
|
32
32
|
spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-schema/issues"
|
33
33
|
|
@@ -47,7 +47,7 @@ module Dry
|
|
47
47
|
pattern: "^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$"
|
48
48
|
},
|
49
49
|
gt?: {exclusiveMinimum: IDENTITY},
|
50
|
-
gteq?: {
|
50
|
+
gteq?: {minimum: IDENTITY},
|
51
51
|
lt?: {exclusiveMaximum: IDENTITY},
|
52
52
|
lteq?: {maximum: IDENTITY},
|
53
53
|
odd?: {type: "integer", not: {multipleOf: 2}},
|
@@ -88,7 +88,7 @@ module Dry
|
|
88
88
|
|
89
89
|
# @api private
|
90
90
|
def visit_set(node, opts = EMPTY_HASH)
|
91
|
-
target = (key = opts[:key]) ? self.class.new : self
|
91
|
+
target = (key = opts[:key]) ? self.class.new(loose: loose?) : self
|
92
92
|
|
93
93
|
node.map { |child| target.visit(child, opts) }
|
94
94
|
|
@@ -114,6 +114,18 @@ module Dry
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
# @api private
|
118
|
+
def visit_or(node, opts = EMPTY_HASH)
|
119
|
+
node.each do |child|
|
120
|
+
c = self.class.new(loose: loose?)
|
121
|
+
c.keys.update(subschema: {})
|
122
|
+
c.visit(child, opts.merge(key: :subschema))
|
123
|
+
|
124
|
+
any_of = (keys[opts[:key]][:anyOf] ||= [])
|
125
|
+
any_of << c.keys[:subschema]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
117
129
|
# @api private
|
118
130
|
def visit_implication(node, opts = EMPTY_HASH)
|
119
131
|
node.each do |el|
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "dry/core/equalizer"
|
4
|
-
|
5
3
|
require "dry/schema/message/or/abstract"
|
6
4
|
require "dry/schema/path"
|
7
5
|
|
@@ -14,23 +12,85 @@ module Dry
|
|
14
12
|
# @api public
|
15
13
|
class MultiPath < Abstract
|
16
14
|
# @api private
|
17
|
-
|
15
|
+
class MessageArray
|
16
|
+
# @api private
|
17
|
+
def initialize(messages)
|
18
|
+
@messages = messages.flatten
|
19
|
+
end
|
20
|
+
|
21
|
+
# @api private
|
22
|
+
def _paths
|
23
|
+
@messages.map(&:_path)
|
24
|
+
end
|
25
|
+
|
26
|
+
# @api private
|
27
|
+
def to_or(root)
|
28
|
+
self.class.new(@messages.map { _1.to_or(root) })
|
29
|
+
end
|
30
|
+
|
31
|
+
# @api private
|
32
|
+
def to_h
|
33
|
+
MessageSet.new(@messages).to_h
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# @api private
|
38
|
+
def self.handler(message)
|
39
|
+
handlers.find { |k,| message.is_a?(k) }&.last
|
40
|
+
end
|
18
41
|
|
19
42
|
# @api private
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
@left = flat_left.map { _1.to_or(root) }
|
26
|
-
@right = flat_right.map { _1.to_or(root) }
|
43
|
+
private_class_method def self.handlers
|
44
|
+
@handlers ||= {
|
45
|
+
self => -> { _1 },
|
46
|
+
Array => -> { MessageArray.new(_1) }
|
47
|
+
}.freeze
|
27
48
|
end
|
28
49
|
|
29
50
|
# @api public
|
30
51
|
def to_h
|
31
|
-
@to_h ||= Path[[*root, :or]].to_h(
|
32
|
-
|
33
|
-
|
52
|
+
@to_h ||= Path[[*root, :or]].to_h(messages.map(&:to_h))
|
53
|
+
end
|
54
|
+
|
55
|
+
# @api private
|
56
|
+
def messages
|
57
|
+
@messages ||= _messages.flat_map { _1.to_or(root) }
|
58
|
+
end
|
59
|
+
|
60
|
+
# @api private
|
61
|
+
def root
|
62
|
+
@root ||= _messages.flat_map(&:_paths).reduce(:&)
|
63
|
+
end
|
64
|
+
|
65
|
+
# @api private
|
66
|
+
def path
|
67
|
+
root
|
68
|
+
end
|
69
|
+
|
70
|
+
# @api private
|
71
|
+
def _paths
|
72
|
+
@paths ||= [Path[root]]
|
73
|
+
end
|
74
|
+
|
75
|
+
# @api private
|
76
|
+
def to_or(root)
|
77
|
+
self.root == root ? messages : [self]
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
# @api private
|
83
|
+
def _messages
|
84
|
+
@_messages ||= [left, right].map do |message|
|
85
|
+
handler = self.class.handler(message)
|
86
|
+
|
87
|
+
unless handler
|
88
|
+
raise ArgumentError,
|
89
|
+
"#{message.inspect} is of unknown type #{message.class.inspect}"
|
90
|
+
end
|
91
|
+
|
92
|
+
handler.(message)
|
93
|
+
end
|
34
94
|
end
|
35
95
|
end
|
36
96
|
end
|
@@ -17,8 +17,8 @@ module Dry
|
|
17
17
|
|
18
18
|
if paths.uniq.size == 1
|
19
19
|
SinglePath.new(left, right, messages)
|
20
|
-
elsif
|
21
|
-
if
|
20
|
+
elsif MultiPath.handler(right)
|
21
|
+
if MultiPath.handler(left) && paths.uniq.size > 1
|
22
22
|
MultiPath.new(left, right)
|
23
23
|
else
|
24
24
|
right
|
@@ -39,10 +39,10 @@ module Dry
|
|
39
39
|
super do |config|
|
40
40
|
config.default_locale = :en unless config.default_locale
|
41
41
|
|
42
|
-
config.root = "%<locale>s.#{config.root}"
|
42
|
+
config.root = -"%<locale>s.#{config.root}"
|
43
43
|
|
44
44
|
config.rule_lookup_paths = config.rule_lookup_paths.map { |path|
|
45
|
-
"%<locale>s.#{path}"
|
45
|
+
-"%<locale>s.#{path}"
|
46
46
|
}
|
47
47
|
end
|
48
48
|
end
|
data/lib/dry/schema/processor.rb
CHANGED
data/lib/dry/schema/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -237,7 +237,7 @@ licenses:
|
|
237
237
|
- MIT
|
238
238
|
metadata:
|
239
239
|
allowed_push_host: https://rubygems.org
|
240
|
-
changelog_uri: https://github.com/dry-rb/dry-schema/blob/
|
240
|
+
changelog_uri: https://github.com/dry-rb/dry-schema/blob/main/CHANGELOG.md
|
241
241
|
source_code_uri: https://github.com/dry-rb/dry-schema
|
242
242
|
bug_tracker_uri: https://github.com/dry-rb/dry-schema/issues
|
243
243
|
post_install_message:
|