foobara-json-schema-generator 1.0.0 → 1.1.0
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 +8 -0
- data/src/json_schema_generator.rb +28 -11
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ada8b771c3996667179a91f625b5bf8855b1b11f9d99dcfdf29405b9da00c29
|
4
|
+
data.tar.gz: d9155a94bcca4a28915ea69f4cae3f1d8bda4449b0f7537f1c851df6f446c887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 961ba1ff36e550f777555be5192b1e59cfc00e58ffab897c5f4301795bc09eb0dbaf0f2bfa5c7363c6318cc54ae7cbb208dedb32e90c0863ad8c480fd8b45ad6
|
7
|
+
data.tar.gz: 807fefe285419e4a1361bf701a8849c497804e17d2de012af5ab57a9e5d55c8a57f469fe06fdf5d56ed1ce68890d3f1a473e89dac5fb5a2d38390268129c335d
|
data/CHANGELOG.md
CHANGED
@@ -41,10 +41,25 @@ module Foobara
|
|
41
41
|
foobara_type_to_json_schema_type_poro(type.target_class.attributes_type, association_depth:,
|
42
42
|
within_entity:)
|
43
43
|
elsif type.extends?(BuiltinTypes[:tuple])
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
element_types = type.element_types
|
45
|
+
size = element_types.size
|
46
|
+
items = element_types.map do |element_type|
|
47
|
+
foobara_type_to_json_schema_type_poro(element_type, association_depth:, within_entity:)
|
48
|
+
end
|
49
|
+
|
50
|
+
uniq_items = items.uniq
|
51
|
+
|
52
|
+
if uniq_items.size == 1
|
53
|
+
items = uniq_items.first
|
54
|
+
end
|
55
|
+
|
56
|
+
{
|
57
|
+
type: "array",
|
58
|
+
additionalItems: false,
|
59
|
+
minItems: size,
|
60
|
+
maxItems: size,
|
61
|
+
items:
|
62
|
+
}
|
48
63
|
elsif type.extends?(BuiltinTypes[:array])
|
49
64
|
items = if type.element_type
|
50
65
|
foobara_type_to_json_schema_type_poro(type.element_type, association_depth:,
|
@@ -102,16 +117,18 @@ module Foobara
|
|
102
117
|
# :nocov:
|
103
118
|
end
|
104
119
|
|
105
|
-
|
120
|
+
unless type.primitive?
|
121
|
+
one_of = DataPath.value_at(:one_of, declaration_data)
|
106
122
|
|
107
|
-
|
108
|
-
|
109
|
-
|
123
|
+
if one_of&.any?
|
124
|
+
type_hash[:enum] = one_of
|
125
|
+
end
|
110
126
|
|
111
|
-
|
127
|
+
allow_nil = DataPath.value_at(:allow_nil, declaration_data)
|
112
128
|
|
113
|
-
|
114
|
-
|
129
|
+
if allow_nil && type_hash.key?(:type)
|
130
|
+
type_hash[:type] = [type_hash[:type], "null"]
|
131
|
+
end
|
115
132
|
end
|
116
133
|
|
117
134
|
if description
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-json-schema-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
@@ -13,16 +13,22 @@ dependencies:
|
|
13
13
|
name: foobara
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
|
-
- - "
|
16
|
+
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 0.
|
18
|
+
version: 0.1.1
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.0.0
|
19
22
|
type: :runtime
|
20
23
|
prerelease: false
|
21
24
|
version_requirements: !ruby/object:Gem::Requirement
|
22
25
|
requirements:
|
23
|
-
- - "
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 0.1.1
|
29
|
+
- - "<"
|
24
30
|
- !ruby/object:Gem::Version
|
25
|
-
version: 0.0
|
31
|
+
version: 2.0.0
|
26
32
|
email:
|
27
33
|
- azimux@gmail.com
|
28
34
|
executables: []
|