json-schema-serializer 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +0 -0
- data/.gitignore +0 -0
- data/.prettierrc +0 -0
- data/.rspec +0 -0
- data/.rubocop.yml +0 -0
- data/.rubocop_airbnb.yml +0 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +0 -0
- data/LICENSE +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/Steepfile +5 -0
- data/json-schema-serializer.gemspec +1 -0
- data/lib/json/schema/serializer.rb +8 -3
- data/lib/json/schema/serializer/version.rb +1 -1
- data/sig/json/schema/serializer.rbs +59 -0
- metadata +24 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 688a9d9a5604e822768c5427964b4b63a4bc1e4a909709672a4ba091c9afd309
|
4
|
+
data.tar.gz: 842ed003063daf2b04c14cee4239d8b2b31c4bdc77426adbc3c231ac80922576
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88ede4a87f75b6f176d177cb078d7336ba67f25923d890a95c727106a14e2c673f6a02593056a3f069b30d517b6b48f344075df7b30e0edac76e1bab58f4fb15
|
7
|
+
data.tar.gz: f797603f80e47cced28a52bddabf61cef290064339d8b25c32b89fd7ebafd2093c46eeaa9b79f6436b557d8315ec23c5153060058f364067f98243cf3222d924
|
data/.github/workflows/ruby.yml
CHANGED
File without changes
|
data/.gitignore
CHANGED
File without changes
|
data/.prettierrc
CHANGED
File without changes
|
data/.rspec
CHANGED
File without changes
|
data/.rubocop.yml
CHANGED
File without changes
|
data/.rubocop_airbnb.yml
CHANGED
File without changes
|
data/CHANGELOG.md
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/Steepfile
ADDED
@@ -38,4 +38,5 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_development_dependency "rubocop-config-prettier", "~> 0.1"
|
39
39
|
spec.add_development_dependency "pry-byebug", "~> 3.7"
|
40
40
|
spec.add_development_dependency "yard", "~> 0.9"
|
41
|
+
spec.add_development_dependency "steep", ">= 0.39"
|
41
42
|
end
|
@@ -6,7 +6,12 @@ module JSON
|
|
6
6
|
class Schema
|
7
7
|
class Serializer
|
8
8
|
def initialize(schema, options = nil) # rubocop:disable Airbnb/OptArgParameters
|
9
|
-
@schema =
|
9
|
+
@schema =
|
10
|
+
if options && (resolver = options[:resolver])
|
11
|
+
resolver.call(schema)
|
12
|
+
else
|
13
|
+
schema
|
14
|
+
end
|
10
15
|
@options = options || {}
|
11
16
|
end
|
12
17
|
|
@@ -212,8 +217,8 @@ module JSON
|
|
212
217
|
nil
|
213
218
|
elsif options[:empty_string_boolean_coerce_null] && obj == ""
|
214
219
|
nil
|
215
|
-
elsif options[:false_values]
|
216
|
-
!
|
220
|
+
elsif (false_values = options[:false_values])
|
221
|
+
!false_values.include?(obj)
|
217
222
|
elsif options[:no_boolean_coerce]
|
218
223
|
obj == true
|
219
224
|
else
|
@@ -0,0 +1,59 @@
|
|
1
|
+
type jsonSchema = untyped
|
2
|
+
type jsonData = untyped
|
3
|
+
type jsonSchemaContext = untyped
|
4
|
+
type jsonSingleType = "null" | "string" | "number" | "integer" | "boolean" | "array" | "object"
|
5
|
+
type jsonType = jsonSingleType | Array[jsonSingleType]
|
6
|
+
|
7
|
+
# Classes
|
8
|
+
module JSON
|
9
|
+
class Schema
|
10
|
+
class Serializer
|
11
|
+
VERSION: String
|
12
|
+
|
13
|
+
type serializerOptions = {
|
14
|
+
inject_key: String | Symbol?,
|
15
|
+
inject_context: jsonSchemaContext?,
|
16
|
+
injectors: Hash[String | Symbol, Class] | Class,
|
17
|
+
inject_by_keyword: bool?,
|
18
|
+
resolver: (^(jsonData data) -> jsonData)?,
|
19
|
+
null_through: bool?,
|
20
|
+
empty_string_number_coerce_null: bool?,
|
21
|
+
empty_string_boolean_coerce_null: bool?,
|
22
|
+
false_values: Enumerable[untyped]?,
|
23
|
+
no_boolean_coerce: bool?,
|
24
|
+
guard_primitive_in_structure: bool?,
|
25
|
+
schema_key_transform_for_input: (^(String name) -> String)?,
|
26
|
+
schema_key_transform_for_output: (^(String name) -> String)?
|
27
|
+
}
|
28
|
+
@schema: jsonSchema
|
29
|
+
@options: serializerOptions
|
30
|
+
|
31
|
+
def initialize: (jsonSchema schema, ?serializerOptions options) -> void
|
32
|
+
def serialize: (jsonData data) -> untyped
|
33
|
+
|
34
|
+
class DataWithContext < Struct[untyped]
|
35
|
+
attr_accessor data(): jsonData
|
36
|
+
attr_accessor context(): jsonSchemaContext
|
37
|
+
def initialize: (data: jsonData, context: jsonSchemaContext) -> void
|
38
|
+
end
|
39
|
+
|
40
|
+
module WithContext
|
41
|
+
ARG2_NOT_GIVEN: :__json_schema_serializer_arg2_not_given__
|
42
|
+
|
43
|
+
def with_context!: (jsonSchemaContext context) { () -> jsonData } -> DataWithContext
|
44
|
+
| (jsonData data, jsonSchemaContext context) -> DataWithContext
|
45
|
+
| ({ data: jsonData, context: jsonSchemaContext } arg) -> DataWithContext
|
46
|
+
end
|
47
|
+
|
48
|
+
class Walker
|
49
|
+
TimeWithZone: nil
|
50
|
+
|
51
|
+
def self.walk: (jsonSchema schema, jsonData obj, bool required, bool using_default, serializerOptions options) -> untyped
|
52
|
+
def self.detect_type: (jsonType type_, jsonData obj) -> jsonSingleType
|
53
|
+
def self.type_coerce: (jsonSchema schema, jsonType type_, String format, jsonData obj, bool required, bool using_default, serializerOptions options) -> untyped
|
54
|
+
def self.try_hash: (untyped obj, String | Symbol? name) -> untyped
|
55
|
+
def self.is_primitive?: (untyped obj) -> bool
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
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: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Narazaka
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -164,7 +164,21 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0.9'
|
167
|
-
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: steep
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.39'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0.39'
|
181
|
+
description:
|
168
182
|
email:
|
169
183
|
- info@narazaka.net
|
170
184
|
executables: []
|
@@ -182,12 +196,14 @@ files:
|
|
182
196
|
- LICENSE
|
183
197
|
- README.md
|
184
198
|
- Rakefile
|
199
|
+
- Steepfile
|
185
200
|
- bin/console
|
186
201
|
- bin/fmt
|
187
202
|
- bin/setup
|
188
203
|
- json-schema-serializer.gemspec
|
189
204
|
- lib/json/schema/serializer.rb
|
190
205
|
- lib/json/schema/serializer/version.rb
|
206
|
+
- sig/json/schema/serializer.rbs
|
191
207
|
homepage: https://github.com/Narazaka/json-schema-serializer
|
192
208
|
licenses:
|
193
209
|
- Zlib
|
@@ -195,8 +211,8 @@ metadata:
|
|
195
211
|
homepage_uri: https://github.com/Narazaka/json-schema-serializer
|
196
212
|
source_code_uri: https://github.com/Narazaka/json-schema-serializer.git
|
197
213
|
changelog_uri: https://github.com/Narazaka/json-schema-serializer/blob/master/CHANGELOG.md
|
198
|
-
documentation_uri: https://www.rubydoc.info/gems/json-schema-serializer/2.0
|
199
|
-
post_install_message:
|
214
|
+
documentation_uri: https://www.rubydoc.info/gems/json-schema-serializer/2.1.0
|
215
|
+
post_install_message:
|
200
216
|
rdoc_options: []
|
201
217
|
require_paths:
|
202
218
|
- lib
|
@@ -211,8 +227,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
227
|
- !ruby/object:Gem::Version
|
212
228
|
version: '0'
|
213
229
|
requirements: []
|
214
|
-
rubygems_version: 3.
|
215
|
-
signing_key:
|
230
|
+
rubygems_version: 3.2.3
|
231
|
+
signing_key:
|
216
232
|
specification_version: 4
|
217
233
|
summary: JSON Schema based serializer
|
218
234
|
test_files: []
|