foobara-json-schema-generator 0.0.5 → 0.0.6

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: 7dbc744ffb92537271cfafd9f469c75aa7661ab6a4c5d395d905e3d95ccd986a
4
- data.tar.gz: 3ca5e0e634cc184e5338dea8e138c5dbc51d6e5c578de2d1b37f914053e6d0df
3
+ metadata.gz: 0aef2e8bba777720358599aeea52118bef2ef4374c2e86b47af6cdd66311103f
4
+ data.tar.gz: 8108afa702a8b91dd66f7717cd0948dc4fa23a85164a3b01ef5547a9191509ba
5
5
  SHA512:
6
- metadata.gz: e3e44501025bc736dbf0ca36be6f599c27756f5610f878b3b48313b4ef697b93707ff8be0aaa57ba144219c05db1f0c263f396b505a626687cb0a27d322bd743
7
- data.tar.gz: 74f1e6bd4cb4c0c359b070df0e31df22667d5447b05fd80bcd6d8d03dca7744a545e4d57d9dadc4516c30a85889fa94d6cf06abfab26eb9c3010922128bb5553
6
+ metadata.gz: 4adc77ee8839324271a8e32a437bc61e958959beaa3bfd4458d26ed528383cbfa1da9d5ec0d51af75df0c82ccab0663b247f25c1e598b92d47f9adfe70a810e4
7
+ data.tar.gz: b58482bea53277e6637c355a0eea32c69e7a34170ee2a45254f1709b8bccfbcaa5ce603dfa5813d0f2a1ba8cf78f63272745c13b7e88f0050af8db753beab36f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.0.6] - 2025-06-19
2
+
3
+ - Improve the description on entity types converted to primary key types
4
+
1
5
  ## [0.0.5] - 2025-05-25
2
6
 
3
7
  - Support :attributes top-level type
@@ -15,21 +15,32 @@ module Foobara
15
15
 
16
16
  private
17
17
 
18
- def foobara_type_to_json_schema_type_poro(type, association_depth:, within_entity: false)
18
+ def foobara_type_to_json_schema_type_poro(type, association_depth:, within_entity: false, description: nil)
19
19
  declaration_data = type.declaration_data
20
20
 
21
- # from other place
22
21
  type_hash = if type.extends?(BuiltinTypes[:entity])
23
22
  target_class = type.target_class
24
23
 
25
- child_type = if association_depth == AssociationDepth::PRIMARY_KEY_ONLY ||
26
- (association_depth == AssociationDepth::ATOM && within_entity)
27
- target_class.primary_key_type
28
- else
29
- target_class.attributes_type
30
- end
24
+ if association_depth == AssociationDepth::PRIMARY_KEY_ONLY ||
25
+ (association_depth == AssociationDepth::ATOM && within_entity)
26
+ description = unless type.extends_directly?(:entity)
27
+ [
28
+ "#{target_class.model_name} #{target_class.primary_key_attribute}",
29
+ type.description
30
+ ].join(" : ")
31
+ end
32
+
33
+ foobara_type_to_json_schema_type_poro(
34
+ target_class.primary_key_type,
35
+ description:,
36
+ association_depth:,
37
+ within_entity: true
38
+ )
39
+ else
40
+ foobara_type_to_json_schema_type_poro(target_class.attributes_type,
41
+ association_depth:, within_entity: true)
42
+ end
31
43
 
32
- foobara_type_to_json_schema_type_poro(child_type, association_depth:, within_entity: true)
33
44
  elsif type.extends?(BuiltinTypes[:model])
34
45
  foobara_type_to_json_schema_type_poro(type.target_class.attributes_type, association_depth:,
35
46
  within_entity:)
@@ -107,7 +118,9 @@ module Foobara
107
118
  type_hash[:type] = [type_hash[:type], "null"]
108
119
  end
109
120
 
110
- if !type.builtin? && type.description
121
+ if description
122
+ type_hash[:description] = description
123
+ elsif !type.builtin? && type.description
111
124
  type_hash[:description] = type.description
112
125
  end
113
126
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-json-schema-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-26 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: foobara
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  requirements: []
62
- rubygems_version: 3.6.2
62
+ rubygems_version: 3.6.9
63
63
  specification_version: 4
64
64
  summary: Takes a Foobara type and converts it to a json schema
65
65
  test_files: []