active_json_schema 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cdfca17ff6cc30e98bba49122db2b8072a3bedf880486ce80574dde8e73d74ba
4
- data.tar.gz: 6209512ebddb4a3903f1ad1762ad16a76a998ddc59a031d7a88a2aefc34ca137
3
+ metadata.gz: 0d5698d9ccd14c35477c6cbc937401bc7c36e96c0298a4388b708c80d59b14d6
4
+ data.tar.gz: c0abbf26c7b8d746db8def01695e8a4b3601ada6163048951eb5ebcf61c44876
5
5
  SHA512:
6
- metadata.gz: f3643c51ef453e218e320617d6521548903734e3c47efb0c22a2bd0fe2b167f07fe85356ee1c6fbe797e6d19cc2a13c38d7bae9675206d86dd769ccdfbfdc479
7
- data.tar.gz: fb09e2a10dd66bd4431a2281c4637f8a552be34620726894b06c76a98be125519f058a64a20b4b1b845bf468eea89c8ebba52a60bea2d6a2ed46246e5346d0d1
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.columns_hash.each do |column_name, column_info|
41
- next unless only.nil? || only.include?(column_name)
42
-
43
- properties[column_name] = column_to_json_property(column_info)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveJsonSchema
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
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.0
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-08 00:00:00.000000000 Z
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.