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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7496c412ff45f1dc6db1b129995b127be3b1b5008b4df3d4c2bb1b9c43b966b2
4
- data.tar.gz: b89116242f86ca0d282eda61a9ca9def2f3f1c16bf34413c40686d3dcd111544
3
+ metadata.gz: 3ada8b771c3996667179a91f625b5bf8855b1b11f9d99dcfdf29405b9da00c29
4
+ data.tar.gz: d9155a94bcca4a28915ea69f4cae3f1d8bda4449b0f7537f1c851df6f446c887
5
5
  SHA512:
6
- metadata.gz: 254bb5befa15e14b7dfff067cb20a547a907820ce5b20f4de41c6777a2a312ce9ac2198ed47c6f57334eded62aff966c5b373700dad16204fc19b37fc64ae1d2
7
- data.tar.gz: ef69c5d5a90cfba4f0f2a28f36dcc8a72d8035c754bb7fad8def4988d87a3b24d0f51055f19f33f7ae2ab73425c5b9ef784ed3c5610042e35c8b69ee2c16d4ac
6
+ metadata.gz: 961ba1ff36e550f777555be5192b1e59cfc00e58ffab897c5f4301795bc09eb0dbaf0f2bfa5c7363c6318cc54ae7cbb208dedb32e90c0863ad8c480fd8b45ad6
7
+ data.tar.gz: 807fefe285419e4a1361bf701a8849c497804e17d2de012af5ab57a9e5d55c8a57f469fe06fdf5d56ed1ce68890d3f1a473e89dac5fb5a2d38390268129c335d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.1.0] - 2025-08-22
2
+
3
+ - Handle Foobara 0.1.0 declaration changes
4
+
5
+ ## [1.0.1] - 2025-07-12
6
+
7
+ - Add support for tuples
8
+
1
9
  ## [1.0.0] - 2025-07-08
2
10
 
3
11
  - Fix bug resulting in incorrect description when converting entity to primary key
@@ -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
- # TODO: implement this logic for tuple
45
- # :nocov:
46
- raise ArgumentError, "Tuple not yet supported"
47
- # :nocov:
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
- one_of = DataPath.value_at(:one_of, declaration_data)
120
+ unless type.primitive?
121
+ one_of = DataPath.value_at(:one_of, declaration_data)
106
122
 
107
- if one_of&.any?
108
- type_hash[:enum] = one_of
109
- end
123
+ if one_of&.any?
124
+ type_hash[:enum] = one_of
125
+ end
110
126
 
111
- allow_nil = DataPath.value_at(:allow_nil, declaration_data)
127
+ allow_nil = DataPath.value_at(:allow_nil, declaration_data)
112
128
 
113
- if allow_nil && type_hash.key?(:type)
114
- type_hash[:type] = [type_hash[:type], "null"]
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.0.0
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.0.92
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.92
31
+ version: 2.0.0
26
32
  email:
27
33
  - azimux@gmail.com
28
34
  executables: []