active_json_schema 0.1.1 → 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: 6be2809c96e9242ac62081da7140052fd55d4aa8f58c889a99a3e18554c58b7b
4
- data.tar.gz: 9030d26a2b56bd4a8208f5f6edf338decc41e8adfd1535eace3e4329234550d0
3
+ metadata.gz: 0d5698d9ccd14c35477c6cbc937401bc7c36e96c0298a4388b708c80d59b14d6
4
+ data.tar.gz: c0abbf26c7b8d746db8def01695e8a4b3601ada6163048951eb5ebcf61c44876
5
5
  SHA512:
6
- metadata.gz: 31215b8f56b4ab78a8adadeed9bbd3760e624fee016670e897a9f9c36abe35f65a12eb8fe486704962d3394a0a067f0e13db4f813ebdf1f3bdfedcd4d298368b
7
- data.tar.gz: f7840b4dd8161270cb66c3c48ead1e0826e12abc36a958d4ca02e651cb528acf0a0509ea2b071d8305c188cfc3796f29360dd7307e5457ae508709a6aeb2c11d
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
@@ -31,10 +32,14 @@ class ConvertsToJsonSchemaWithRefs
31
32
  def properties_for(model_class, only, associations)
32
33
  properties = {}
33
34
 
34
- model_class.columns_hash.each do |column_name, column_info|
35
- next unless only.nil? || only.include?(column_name)
36
-
37
- 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
+ )
38
43
  end
39
44
 
40
45
  associations.each do |association_name, options|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveJsonSchema
4
- VERSION = "0.1.1"
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.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-09 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.