typelizer 0.9.0 → 0.9.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 +9 -1
- data/lib/typelizer/interface.rb +1 -1
- data/lib/typelizer/model_plugins/active_record.rb +18 -6
- data/lib/typelizer/openapi.rb +1 -1
- data/lib/typelizer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82ca16632db02541212afb1fa0cd9b47bbaa10a375b68c4d830e4264eeec5fd8
|
|
4
|
+
data.tar.gz: c12d5e0a2aea772483d92b8290dcfa9c6a5e5e38febebf3d986db126f00e4d87
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e04629e8669b5ed6c610c85246ea06d3bda46100d2d9d876ad2d0ae6904669aeb569b689b4634df39217a392028bb968060f30a7b4f1f6a47c6374c0604d84d
|
|
7
|
+
data.tar.gz: ba808f9f614f856fcd6f3c496b990bbb1ead4530e0214d3d55cbadd62a63e5a9846623ff446d006570d5b4c2b499bfe7bb46c9049c95dc74caf9df81e7a80187
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning].
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.9.1] - 2026-02-26
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Fix crash when using tuple types in serializers. ([@skryukov])
|
|
15
|
+
- Handle abstract ActiveRecord classes gracefully during type inference. ([@skryukov])
|
|
16
|
+
|
|
10
17
|
## [0.9.0] - 2026-02-26
|
|
11
18
|
|
|
12
19
|
### Added
|
|
@@ -413,7 +420,8 @@ and this project adheres to [Semantic Versioning].
|
|
|
413
420
|
[@skryukov]: https://github.com/skryukov
|
|
414
421
|
[@ventsislaf]: https://github.com/ventsislaf
|
|
415
422
|
|
|
416
|
-
[Unreleased]: https://github.com/skryukov/typelizer/compare/v0.9.
|
|
423
|
+
[Unreleased]: https://github.com/skryukov/typelizer/compare/v0.9.1...HEAD
|
|
424
|
+
[0.9.1]: https://github.com/skryukov/typelizer/compare/v0.9.0...v0.9.1
|
|
417
425
|
[0.9.0]: https://github.com/skryukov/typelizer/compare/v0.8.0...v0.9.0
|
|
418
426
|
[0.8.0]: https://github.com/skryukov/typelizer/compare/v0.7.0...v0.8.0
|
|
419
427
|
[0.7.0]: https://github.com/skryukov/typelizer/compare/v0.6.0...v0.7.0
|
data/lib/typelizer/interface.rb
CHANGED
|
@@ -19,7 +19,7 @@ module Typelizer
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def comment_for(prop)
|
|
22
|
-
column =
|
|
22
|
+
column = columns_hash&.dig(prop.column_name.to_s)
|
|
23
23
|
return nil unless column
|
|
24
24
|
|
|
25
25
|
prop.comment = column.comment
|
|
@@ -35,6 +35,20 @@ module Typelizer
|
|
|
35
35
|
|
|
36
36
|
private
|
|
37
37
|
|
|
38
|
+
def columns_hash
|
|
39
|
+
return nil unless model_class
|
|
40
|
+
return nil if model_class.abstract_class?
|
|
41
|
+
|
|
42
|
+
model_class.columns_hash
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def attribute_types
|
|
46
|
+
return nil unless model_class&.respond_to?(:attribute_types)
|
|
47
|
+
return nil if model_class.abstract_class?
|
|
48
|
+
|
|
49
|
+
model_class.attribute_types
|
|
50
|
+
end
|
|
51
|
+
|
|
38
52
|
def infer_types_for_association(prop)
|
|
39
53
|
association = model_class&.reflect_on_association(prop.column_name.to_sym)
|
|
40
54
|
return nil unless association
|
|
@@ -42,7 +56,7 @@ module Typelizer
|
|
|
42
56
|
case association.macro
|
|
43
57
|
when :belongs_to
|
|
44
58
|
foreign_key = association.foreign_key
|
|
45
|
-
column =
|
|
59
|
+
column = columns_hash&.dig(foreign_key.to_s)
|
|
46
60
|
if config.associations_strategy == :database
|
|
47
61
|
prop.nullable = column.null if column
|
|
48
62
|
elsif config.associations_strategy == :active_record
|
|
@@ -64,7 +78,7 @@ module Typelizer
|
|
|
64
78
|
end
|
|
65
79
|
|
|
66
80
|
def infer_types_for_column(prop)
|
|
67
|
-
column =
|
|
81
|
+
column = columns_hash&.dig(prop.column_name.to_s)
|
|
68
82
|
return nil unless column
|
|
69
83
|
|
|
70
84
|
prop.column_type = column.type
|
|
@@ -122,9 +136,7 @@ module Typelizer
|
|
|
122
136
|
end
|
|
123
137
|
|
|
124
138
|
def infer_types_for_attribute(prop)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
attribute_type_obj = model_class.attribute_types.fetch(prop.column_name.to_s, nil)
|
|
139
|
+
attribute_type_obj = attribute_types&.fetch(prop.column_name.to_s, nil)
|
|
128
140
|
return nil unless attribute_type_obj
|
|
129
141
|
|
|
130
142
|
if attribute_type_obj.instance_of?(::ActiveRecord::Type::Serialized)
|
data/lib/typelizer/openapi.rb
CHANGED
|
@@ -203,7 +203,7 @@ module Typelizer
|
|
|
203
203
|
end
|
|
204
204
|
|
|
205
205
|
def ts_only_type?(type_str)
|
|
206
|
-
type_str.start_with?("{") || type_str.include?("<") || TS_OBJECT_TYPES.include?(type_str)
|
|
206
|
+
type_str.start_with?("{", "[") || type_str.include?("<") || TS_OBJECT_TYPES.include?(type_str)
|
|
207
207
|
end
|
|
208
208
|
|
|
209
209
|
def validate_version!(openapi_version)
|
data/lib/typelizer/version.rb
CHANGED