active_json_schema 0.1.0 → 0.1.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d5698d9ccd14c35477c6cbc937401bc7c36e96c0298a4388b708c80d59b14d6
|
4
|
+
data.tar.gz: c0abbf26c7b8d746db8def01695e8a4b3601ada6163048951eb5ebcf61c44876
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad817ef2de47ccac9fd446e8418f562c5cbd6efaa16e1d19cec4d0f0242730c12b1c4db8086885d90d29e544f01f3e3b45de7cd42651107fe3e56bdfb59c5bee
|
7
|
+
data.tar.gz: '0387af4040357217eee54a97928798d9a9fc0a3f50b0fd44f3abe1bd0802d75c24843ef3cafddf61a82bf8f947287012ddd997d24cce3574b3048b785f594637'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.2] - 2024-10-10
|
4
|
+
|
3
5
|
### Added
|
4
6
|
- Comprehensive README with installation instructions, usage examples, and customization options
|
5
7
|
- Filled in gemspec with summary, description, and metadata
|
@@ -7,6 +9,10 @@
|
|
7
9
|
- Customizable schema generation with options for specific attributes and associations
|
8
10
|
- Ability to include nested associations in schema generation
|
9
11
|
|
12
|
+
## [0.1.1] - 2024-10-09
|
13
|
+
|
14
|
+
- No changes (version bump only)
|
15
|
+
|
10
16
|
## [0.1.0] - 2024-10-08
|
11
17
|
|
12
18
|
- Initial release
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
class ConvertsToJsonSchemaWithRefs
|
4
4
|
class UnsupportedAssociationType < StandardError; end
|
5
|
+
SchemaAttributeInfo = Struct.new(:type, keyword_init: true)
|
5
6
|
|
6
7
|
def self.generate(model_class, only: nil, associations: {}, additional_properties: false)
|
7
8
|
new(model_class, only: only, associations: associations, additional_properties: additional_properties).generate
|
@@ -29,25 +30,20 @@ class ConvertsToJsonSchemaWithRefs
|
|
29
30
|
private
|
30
31
|
|
31
32
|
def properties_for(model_class, only, associations)
|
32
|
-
puts "properties_for(...)"
|
33
|
-
puts "model_class: #{model_class}"
|
34
|
-
puts "only: #{only}"
|
35
|
-
puts "associations: #{associations}"
|
36
|
-
puts
|
37
|
-
|
38
33
|
properties = {}
|
39
34
|
|
40
|
-
model_class.
|
41
|
-
|
42
|
-
|
43
|
-
|
35
|
+
Array(only || model_class.column_names).each do |name, type|
|
36
|
+
properties[name] = column_to_json_property(
|
37
|
+
if type
|
38
|
+
SchemaAttributeInfo.new(type: type)
|
39
|
+
else
|
40
|
+
model_class.columns_hash[name] || SchemaAttributeInfo.new(type: "string")
|
41
|
+
end
|
42
|
+
)
|
44
43
|
end
|
45
44
|
|
46
|
-
puts "associations.each do |association_name, options|"
|
47
45
|
associations.each do |association_name, options|
|
48
|
-
puts "association_name: #{association_name}"
|
49
46
|
association = model_class.reflect_on_association(association_name)
|
50
|
-
puts "association: #{association}"
|
51
47
|
next unless association
|
52
48
|
|
53
49
|
definition_name = association.klass.name.underscore
|
@@ -72,9 +68,6 @@ class ConvertsToJsonSchemaWithRefs
|
|
72
68
|
end
|
73
69
|
|
74
70
|
def generate_definition(model_class, options)
|
75
|
-
puts "generate_definition(...)"
|
76
|
-
puts "model_class: #{model_class}"
|
77
|
-
puts "options: #{options}"
|
78
71
|
only = options[:only]
|
79
72
|
nested_associations = options[:associations] || {}
|
80
73
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_json_schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kaleb Lape
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ActiveJsonSchema extends ActiveRecord models to generate JSON Schema
|
14
14
|
representations, including support for associations.
|