json-schema-serializer 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +6 -0
- data/lib/json/schema/serializer.rb +13 -1
- data/lib/json/schema/serializer/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: 4b4c5d9d360e8b71d59ffaf2dbaef3a19cb782acdbb4c97548188f4c3339d654
|
4
|
+
data.tar.gz: 180e413608d626170441274fa43c82a20cf62d78a5509cc1cee6b8ade65dbeae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b5e545a90241344d73da7d4a015ba83e0d96ec71df27f98652f755018c2c241b612cdbbcbdcf0b3fc5b10a447e493047a035cdf93c770f42214a41e90935b7b
|
7
|
+
data.tar.gz: 8c875c4c2681df2ef05ae8bde119c6cd1a9cc6621e667616e8df935acfe34c2a4c459cf648730aa9e9439240d805382ff9d8033f2edecd804e8a697def9877e5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -114,6 +114,12 @@ serializer_injected.serialize([1, 2, 3])
|
|
114
114
|
# => {"first"=>1, "count"=>3}
|
115
115
|
```
|
116
116
|
|
117
|
+
### "additionalProperties"
|
118
|
+
|
119
|
+
"additionalProperties" is allowed but must be a schema object. (not boolean)
|
120
|
+
|
121
|
+
If "additionalProperties" does not exists, this serializer works as `{ additionalProperties": false }`.
|
122
|
+
|
117
123
|
### `$ref` resolving
|
118
124
|
|
119
125
|
`JSON::Schema::Serializer` does not resolve `$ref` so use external resolver.
|
@@ -163,10 +163,22 @@ module JSON
|
|
163
163
|
obj.nil? ? [] : obj.map { |item| walk(items_schema, item, true, options) }
|
164
164
|
when "object"
|
165
165
|
properties_schema = try_hash(schema, :properties)
|
166
|
+
additional_properties_schema = try_hash(schema, :additionalProperties)
|
166
167
|
required_schema = Set.new(try_hash(schema, :required)&.map(&:to_s))
|
167
|
-
properties_schema.map do |name, property_schema|
|
168
|
+
ret = properties_schema.map do |name, property_schema|
|
168
169
|
[name.to_s, walk(property_schema, try_hash(obj, name), required_schema.include?(name.to_s), options)]
|
169
170
|
end.to_h
|
171
|
+
if additional_properties_schema
|
172
|
+
not_additional_keys = Set.new(properties_schema.keys.map(&:to_s))
|
173
|
+
additional_keys = obj.keys.reject { |key| not_additional_keys.include?(key.to_s) }
|
174
|
+
ret.merge(
|
175
|
+
additional_keys.map do |name|
|
176
|
+
[name.to_s, walk(additional_properties_schema, try_hash(obj, name), false, options)]
|
177
|
+
end.to_h
|
178
|
+
)
|
179
|
+
else
|
180
|
+
ret
|
181
|
+
end
|
170
182
|
end
|
171
183
|
end
|
172
184
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json-schema-serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Narazaka
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -181,7 +181,7 @@ metadata:
|
|
181
181
|
homepage_uri: https://github.com/Narazaka/json-schema-serializer
|
182
182
|
source_code_uri: https://github.com/Narazaka/json-schema-serializer.git
|
183
183
|
changelog_uri: https://github.com/Narazaka/json-schema-serializer/blob/master/CHANGELOG.md
|
184
|
-
documentation_uri: https://www.rubydoc.info/gems/json-schema-serializer/1.
|
184
|
+
documentation_uri: https://www.rubydoc.info/gems/json-schema-serializer/1.4.0
|
185
185
|
post_install_message:
|
186
186
|
rdoc_options: []
|
187
187
|
require_paths:
|