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 +4 -4
- data/CHANGELOG.md +4 -0
- data/src/json_schema_generator.rb +23 -10
- 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: 0aef2e8bba777720358599aeea52118bef2ef4374c2e86b47af6cdd66311103f
|
4
|
+
data.tar.gz: 8108afa702a8b91dd66f7717cd0948dc4fa23a85164a3b01ef5547a9191509ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4adc77ee8839324271a8e32a437bc61e958959beaa3bfd4458d26ed528383cbfa1da9d5ec0d51af75df0c82ccab0663b247f25c1e598b92d47f9adfe70a810e4
|
7
|
+
data.tar.gz: b58482bea53277e6637c355a0eea32c69e7a34170ee2a45254f1709b8bccfbcaa5ce603dfa5813d0f2a1ba8cf78f63272745c13b7e88f0050af8db753beab36f
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
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.
|
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:
|
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.
|
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: []
|