foobara-json-schema-generator 0.0.6 → 1.0.1
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 +25 -14
- metadata +11 -6
- data/src/association_depth.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 941cc81aba10dd18bb19c8b8427033e76247b4487e827aba21c77c71b5b5ed79
|
4
|
+
data.tar.gz: 30d402402fe3ba09559aebfc141f6b770afd7c944a895cb9e6c1ce7b01dc7859
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8687222ac9cd86b7792aff4b6a2604172ba1c191e81fc0c88a487685cb016b2e73150bb5b5387e2f8aa77b7dab45f3ffaef63d1bba646851ec426f4e5581209e
|
7
|
+
data.tar.gz: 4921a18e39e14b4dd9e5ae3fb41af9cc6eee0e045da79ff836e5b452e9c9b7131d7b30020d35fecd668c84c43bcc499726da48044d814cbcb88d1e634a59bd41
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [1.0.1] - 2025-07-12
|
2
|
+
|
3
|
+
- Add support for tuples
|
4
|
+
|
5
|
+
## [1.0.0] - 2025-07-08
|
6
|
+
|
7
|
+
- Fix bug resulting in incorrect description when converting entity to primary key
|
8
|
+
|
1
9
|
## [0.0.6] - 2025-06-19
|
2
10
|
|
3
11
|
- Improve the description on entity types converted to primary key types
|
@@ -1,15 +1,13 @@
|
|
1
|
-
require_relative "association_depth"
|
2
|
-
|
3
1
|
module Foobara
|
4
2
|
module JsonSchemaGenerator
|
5
3
|
class << self
|
6
|
-
def to_json_schema(type, association_depth: AssociationDepth::ATOM)
|
4
|
+
def to_json_schema(type, association_depth: Foobara::AssociationDepth::ATOM)
|
7
5
|
poro = to_json_schema_structure(type, association_depth:)
|
8
6
|
|
9
7
|
JSON.fast_generate(poro)
|
10
8
|
end
|
11
9
|
|
12
|
-
def to_json_schema_structure(type, association_depth: AssociationDepth::ATOM)
|
10
|
+
def to_json_schema_structure(type, association_depth: Foobara::AssociationDepth::ATOM)
|
13
11
|
foobara_type_to_json_schema_type_poro(type, association_depth:)
|
14
12
|
end
|
15
13
|
|
@@ -23,12 +21,10 @@ module Foobara
|
|
23
21
|
|
24
22
|
if association_depth == AssociationDepth::PRIMARY_KEY_ONLY ||
|
25
23
|
(association_depth == AssociationDepth::ATOM && within_entity)
|
26
|
-
description =
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
].join(" : ")
|
31
|
-
end
|
24
|
+
description = [
|
25
|
+
"#{target_class.model_name} #{target_class.primary_key_attribute}",
|
26
|
+
*type.description
|
27
|
+
].join(" : ")
|
32
28
|
|
33
29
|
foobara_type_to_json_schema_type_poro(
|
34
30
|
target_class.primary_key_type,
|
@@ -45,10 +41,25 @@ module Foobara
|
|
45
41
|
foobara_type_to_json_schema_type_poro(type.target_class.attributes_type, association_depth:,
|
46
42
|
within_entity:)
|
47
43
|
elsif type.extends?(BuiltinTypes[:tuple])
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
+
}
|
52
63
|
elsif type.extends?(BuiltinTypes[:array])
|
53
64
|
items = if type.element_type
|
54
65
|
foobara_type_to_json_schema_type_poro(type.element_type, association_depth:,
|
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:
|
4
|
+
version: 1.0.1
|
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.
|
18
|
+
version: 0.0.136
|
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.0.136
|
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: []
|
@@ -35,7 +41,6 @@ files:
|
|
35
41
|
- LICENSE.txt
|
36
42
|
- README.md
|
37
43
|
- lib/foobara/json_schema_generator.rb
|
38
|
-
- src/association_depth.rb
|
39
44
|
- src/json_schema_generator.rb
|
40
45
|
homepage: https://github.com/foobara/json-schema-generator
|
41
46
|
licenses:
|