deimos-ruby 2.0.4 → 2.0.5
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 +4 -0
- data/lib/deimos/schema_backends/avro_schema_coercer.rb +39 -1
- data/lib/deimos/version.rb +1 -1
- data/lib/generators/deimos/schema_class/templates/schema_record.rb.tt +18 -0
- data/lib/generators/deimos/schema_class_generator.rb +17 -2
- data/spec/active_record_producer_spec.rb +111 -5
- data/spec/schemas/com/my-namespace/MySchemaWithUnionType.avsc +91 -0
- data/spec/schemas/my_namespace/my_schema_with_union_type.rb +185 -0
- data/spec/snapshots/consumers-no-nest.snap +232 -0
- data/spec/snapshots/consumers.snap +202 -0
- data/spec/snapshots/consumers_and_producers-no-nest.snap +232 -0
- data/spec/snapshots/consumers_and_producers.snap +202 -0
- data/spec/snapshots/consumers_circular-no-nest.snap +232 -0
- data/spec/snapshots/consumers_circular.snap +202 -0
- data/spec/snapshots/consumers_complex_types-no-nest.snap +232 -0
- data/spec/snapshots/consumers_complex_types.snap +202 -0
- data/spec/snapshots/consumers_nested-no-nest.snap +232 -0
- data/spec/snapshots/consumers_nested.snap +202 -0
- data/spec/snapshots/namespace_folders.snap +202 -0
- data/spec/snapshots/namespace_map.snap +202 -0
- data/spec/snapshots/producers_with_key-no-nest.snap +232 -0
- data/spec/snapshots/producers_with_key.snap +202 -0
- data/spec/spec_helper.rb +25 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53cd09a846fed14b74b20cad18fc63374887c0a9deae4444f2d6548ea06b5b72
|
4
|
+
data.tar.gz: 95f7b6402d43d2c2332f5abbc8c0374655b1ac713b484d3f4b516321b4e2207d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 928b533075a3a98f5731f15e2e9436cd1ad0754006bcf18816bdc19933e0990478aa7cd06152e450f0041524cfcf04da839c1116a4895bf3c9e692e70aefa4f0
|
7
|
+
data.tar.gz: b363497c5b9f1e9ea6dd71bf2d4e4bd59e7b96fe229cc58ee9caccb3ca86a7cd1ef4bf0636e7a354d496c790aa867fcad3405bdd4b353e72fce1d1e22ba32876
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## UNRELEASED
|
9
9
|
|
10
|
+
## 2.0.5 - 2025-03-19
|
11
|
+
|
12
|
+
- Fix: Added support to handle producing union type of multiple records & data types.
|
13
|
+
|
10
14
|
## 2.0.4 - 2025-03-17
|
11
15
|
|
12
16
|
- Feature: Added `producers.truncate_columns` config.
|
@@ -18,10 +18,48 @@ module Deimos
|
|
18
18
|
union_types = type.schemas.map { |s| s.type.to_sym }
|
19
19
|
return nil if val.nil? && union_types.include?(:null)
|
20
20
|
|
21
|
-
schema_type = type
|
21
|
+
schema_type = find_schema_type(type, val)
|
22
22
|
coerce_type(schema_type, val)
|
23
23
|
end
|
24
24
|
|
25
|
+
# Find the right schema for val from a UnionSchema.
|
26
|
+
# @param type [Avro::Schema::UnionSchema]
|
27
|
+
# @param val [Object]
|
28
|
+
# @return [Avro::Schema::PrimitiveSchema]
|
29
|
+
def find_schema_type(type, val)
|
30
|
+
int_classes = [Time, ActiveSupport::TimeWithZone]
|
31
|
+
|
32
|
+
schema_type = type.schemas.find do |schema|
|
33
|
+
field_type = schema.type.to_sym
|
34
|
+
|
35
|
+
case field_type
|
36
|
+
when :int, :long
|
37
|
+
val.is_a?(Integer) ||
|
38
|
+
_is_integer_string?(val) ||
|
39
|
+
int_classes.any? { |klass| val.is_a?(klass) }
|
40
|
+
when :float, :double
|
41
|
+
val.is_a?(Numeric) || _is_float_string?(val)
|
42
|
+
when :array
|
43
|
+
val.is_a?(Array)
|
44
|
+
when :record
|
45
|
+
if val.is_a?(Hash)
|
46
|
+
schema_fields_set = Set.new(schema.fields.map(&:name))
|
47
|
+
Set.new(val.keys).subset?(schema_fields_set)
|
48
|
+
else
|
49
|
+
# If the value is not a hash, we can't coerce it to a record.
|
50
|
+
# Keep looking for another schema
|
51
|
+
false
|
52
|
+
end
|
53
|
+
else
|
54
|
+
schema.type.to_sym != :null
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
raise "No Schema type found for VALUE: #{val}\n TYPE: #{type}" if schema_type.nil?
|
59
|
+
|
60
|
+
schema_type
|
61
|
+
end
|
62
|
+
|
25
63
|
# Coerce sub-records in a payload to match the schema.
|
26
64
|
# @param type [Avro::Schema::RecordSchema]
|
27
65
|
# @param val [Object]
|
data/lib/deimos/version.rb
CHANGED
@@ -44,6 +44,24 @@
|
|
44
44
|
end
|
45
45
|
|
46
46
|
<%- end -%>
|
47
|
+
<% end -%>
|
48
|
+
<%- if @field_assignments.select{ |h| h[:is_complex_union] }.any? -%>
|
49
|
+
<%- @field_assignments.select{ |h| h[:is_complex_union] }.each do |method_definition| -%>
|
50
|
+
# Helper method to determine which schema type to use for <%= method_definition[:field].name %>
|
51
|
+
# @param value [Hash, nil]
|
52
|
+
# @return [Object, nil]
|
53
|
+
def initialize_<%= method_definition[:field].name %>_type(value)
|
54
|
+
return nil if value.nil?
|
55
|
+
|
56
|
+
klass = [<%= method_definition[:field].type.schemas.reject { |s| s.type_sym == :null }.select { |s| s.type_sym == :record }.map { |s| Deimos::SchemaBackends::AvroBase.schema_classname(s) }.join(', ') %>].find do |candidate|
|
57
|
+
fields = candidate.new.as_json.keys
|
58
|
+
(value.keys - fields).empty?
|
59
|
+
end
|
60
|
+
|
61
|
+
klass.initialize_from_value(value)
|
62
|
+
end
|
63
|
+
|
64
|
+
<%- end -%>
|
47
65
|
<% end -%>
|
48
66
|
# @override
|
49
67
|
<%= @initialization_definition %>
|
@@ -298,7 +298,9 @@ module Deimos
|
|
298
298
|
|
299
299
|
field_initialization = method_argument
|
300
300
|
|
301
|
-
if
|
301
|
+
if _is_complex_union?(field)
|
302
|
+
field_initialization = "initialize_#{field.name}_type(value)"
|
303
|
+
elsif is_schema_class
|
302
304
|
field_initialization = "#{field_base_type}.initialize_from_value(value)"
|
303
305
|
end
|
304
306
|
|
@@ -308,13 +310,26 @@ module Deimos
|
|
308
310
|
is_schema_class: is_schema_class,
|
309
311
|
method_argument: method_argument,
|
310
312
|
deimos_type: deimos_field_type(field),
|
311
|
-
field_initialization: field_initialization
|
313
|
+
field_initialization: field_initialization,
|
314
|
+
is_complex_union: _is_complex_union?(field)
|
312
315
|
}
|
313
316
|
end
|
314
317
|
|
315
318
|
result
|
316
319
|
end
|
317
320
|
|
321
|
+
# Helper method to detect if a field is a complex union type with multiple record schemas
|
322
|
+
# @param field [Deimos::SchemaField]
|
323
|
+
# @return [Boolean]
|
324
|
+
def _is_complex_union?(field)
|
325
|
+
return false unless field.type.type_sym == :union
|
326
|
+
|
327
|
+
non_null_schemas = field.type.schemas.reject { |s| s.type_sym == :null }
|
328
|
+
|
329
|
+
record_schemas = non_null_schemas.select { |s| s.type_sym == :record }
|
330
|
+
record_schemas.length > 1
|
331
|
+
end
|
332
|
+
|
318
333
|
# Converts Avro::Schema::NamedSchema's to String form for generated YARD docs.
|
319
334
|
# Recursively handles the typing for Arrays, Maps and Unions.
|
320
335
|
# @param avro_schema [Avro::Schema::NamedSchema]
|
@@ -3,6 +3,7 @@
|
|
3
3
|
describe Deimos::ActiveRecordProducer do
|
4
4
|
|
5
5
|
include_context 'with widgets'
|
6
|
+
include_context 'with widget_with_union_types'
|
6
7
|
|
7
8
|
prepend_before(:each) do
|
8
9
|
producer_class = Class.new(Deimos::ActiveRecordProducer)
|
@@ -40,6 +41,12 @@ describe Deimos::ActiveRecordProducer do
|
|
40
41
|
end
|
41
42
|
|
42
43
|
stub_const('MyProducerWithPostProcess', producer_class)
|
44
|
+
|
45
|
+
producer_class = Class.new(Deimos::ActiveRecordProducer) do
|
46
|
+
record_class WidgetWithUnionType
|
47
|
+
end
|
48
|
+
stub_const('MyProducerWithUnionType', producer_class)
|
49
|
+
|
43
50
|
Karafka::App.routes.redraw do
|
44
51
|
topic 'my-topic' do
|
45
52
|
schema 'MySchema'
|
@@ -71,6 +78,13 @@ describe Deimos::ActiveRecordProducer do
|
|
71
78
|
key_config none: true
|
72
79
|
producer_class MyProducerWithPostProcess
|
73
80
|
end
|
81
|
+
topic 'my-topic-with-union-type' do
|
82
|
+
schema 'MySchemaWithUnionType'
|
83
|
+
namespace 'com.my-namespace'
|
84
|
+
key_config none: true
|
85
|
+
producer_class MyProducerWithUnionType
|
86
|
+
end
|
87
|
+
|
74
88
|
end
|
75
89
|
|
76
90
|
end
|
@@ -90,6 +104,98 @@ describe Deimos::ActiveRecordProducer do
|
|
90
104
|
expect('my-topic').to have_sent(test_id: 'abc', some_int: 3)
|
91
105
|
end
|
92
106
|
|
107
|
+
it 'should coerce values for a UnionSchema' do
|
108
|
+
MyProducerWithUnionType.send_event(WidgetWithUnionType.new(
|
109
|
+
test_id: "abc",
|
110
|
+
test_long: 399999,
|
111
|
+
test_union_type: %w(hello world)
|
112
|
+
))
|
113
|
+
|
114
|
+
expect('my-topic-with-union-type').to have_sent(
|
115
|
+
test_id: "abc",
|
116
|
+
test_long: 399999,
|
117
|
+
test_union_type: %w(hello world)
|
118
|
+
)
|
119
|
+
|
120
|
+
MyProducerWithUnionType.send_event(WidgetWithUnionType.new(
|
121
|
+
test_id: "abc",
|
122
|
+
test_long: 399999,
|
123
|
+
test_union_type: {
|
124
|
+
record1_map:{ a:9999, b:234 },
|
125
|
+
record1_id: 567
|
126
|
+
}
|
127
|
+
))
|
128
|
+
|
129
|
+
expect('my-topic-with-union-type').to have_sent(
|
130
|
+
test_id: "abc",
|
131
|
+
test_long: 399999,
|
132
|
+
test_union_type:{
|
133
|
+
record1_map:{ a:9999, b:234 },
|
134
|
+
record1_id: 567
|
135
|
+
}
|
136
|
+
)
|
137
|
+
|
138
|
+
MyProducerWithUnionType.send_event(WidgetWithUnionType.new(
|
139
|
+
test_id: "abc",
|
140
|
+
test_long: 399999,
|
141
|
+
test_union_type: 1010101
|
142
|
+
))
|
143
|
+
|
144
|
+
expect('my-topic-with-union-type').to have_sent(
|
145
|
+
test_id: "abc",
|
146
|
+
test_long: 399999,
|
147
|
+
test_union_type:1010101
|
148
|
+
)
|
149
|
+
|
150
|
+
MyProducerWithUnionType.send_event(WidgetWithUnionType.new(
|
151
|
+
test_id: "abc",
|
152
|
+
test_long: 399999,
|
153
|
+
test_union_type: {
|
154
|
+
record2_id: "hello world"
|
155
|
+
}
|
156
|
+
))
|
157
|
+
|
158
|
+
expect('my-topic-with-union-type').to have_sent(
|
159
|
+
test_id: "abc",
|
160
|
+
test_long: 399999,
|
161
|
+
test_union_type: {
|
162
|
+
record2_id: "hello world"
|
163
|
+
}
|
164
|
+
)
|
165
|
+
|
166
|
+
MyProducerWithUnionType.send_event(WidgetWithUnionType.new(
|
167
|
+
test_id: "abc",
|
168
|
+
test_long: 399999,
|
169
|
+
test_union_type: {
|
170
|
+
record3_id:10.1010
|
171
|
+
}
|
172
|
+
))
|
173
|
+
|
174
|
+
expect('my-topic-with-union-type').to have_sent(
|
175
|
+
test_id: "abc",
|
176
|
+
test_long: 399999,
|
177
|
+
test_union_type: {
|
178
|
+
record3_id:10.1010
|
179
|
+
}
|
180
|
+
)
|
181
|
+
|
182
|
+
MyProducerWithUnionType.send_event(WidgetWithUnionType.new(
|
183
|
+
test_id: "abc",
|
184
|
+
test_long: 399999,
|
185
|
+
test_union_type: {
|
186
|
+
record4_id:101010
|
187
|
+
}
|
188
|
+
))
|
189
|
+
|
190
|
+
expect('my-topic-with-union-type').to have_sent(
|
191
|
+
test_id: "abc",
|
192
|
+
test_long: 399999,
|
193
|
+
test_union_type: {
|
194
|
+
record4_id:101010
|
195
|
+
}
|
196
|
+
)
|
197
|
+
end
|
198
|
+
|
93
199
|
it 'should coerce values' do
|
94
200
|
MyProducer.send_event(Widget.new(test_id: 'abc', some_int: '3'))
|
95
201
|
MyProducer.send_event(Widget.new(test_id: 'abc', some_int: 4.5))
|
@@ -109,11 +215,11 @@ describe Deimos::ActiveRecordProducer do
|
|
109
215
|
widget = Widget.create!(test_id: 'abc2', some_int: 3)
|
110
216
|
MyProducerWithID.send_event({id: widget.id, test_id: 'abc2', some_int: 3})
|
111
217
|
expect('my-topic-with-id').to have_sent(
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
218
|
+
test_id: 'abc2',
|
219
|
+
some_int: 3,
|
220
|
+
message_id: 'generated_id',
|
221
|
+
timestamp: anything
|
222
|
+
)
|
117
223
|
end
|
118
224
|
|
119
225
|
it 'should post process the batch of records in #send_events' do
|
@@ -0,0 +1,91 @@
|
|
1
|
+
{
|
2
|
+
"namespace": "com.my-namespace",
|
3
|
+
"name": "MySchemaWithUnionType",
|
4
|
+
"type": "record",
|
5
|
+
"doc": "Test schema",
|
6
|
+
"fields": [
|
7
|
+
{
|
8
|
+
"name": "test_id",
|
9
|
+
"type": "string",
|
10
|
+
"default": ""
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"name": "test_long",
|
14
|
+
"type": [
|
15
|
+
"null",
|
16
|
+
"long"
|
17
|
+
],
|
18
|
+
"default": null
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"name": "test_union_type",
|
22
|
+
"type": [
|
23
|
+
"null",
|
24
|
+
{
|
25
|
+
"type": "record",
|
26
|
+
"name": "Record1",
|
27
|
+
"namespace": "com.flipp.content",
|
28
|
+
"fields": [
|
29
|
+
{
|
30
|
+
"name": "record1_map",
|
31
|
+
"type": {
|
32
|
+
"type": "map",
|
33
|
+
"values": "long"
|
34
|
+
},
|
35
|
+
"default": {}
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"name": "record1_id",
|
39
|
+
"type": "int",
|
40
|
+
"default": 0
|
41
|
+
}
|
42
|
+
]
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"type": "record",
|
46
|
+
"name": "Record2",
|
47
|
+
"namespace": "com.flipp.content",
|
48
|
+
"fields": [
|
49
|
+
{
|
50
|
+
"name": "record2_id",
|
51
|
+
"type": "string",
|
52
|
+
"default": ""
|
53
|
+
}
|
54
|
+
]
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"type": "record",
|
58
|
+
"name": "Record3",
|
59
|
+
"namespace": "com.flipp.content",
|
60
|
+
"fields": [
|
61
|
+
{
|
62
|
+
"name": "record3_id",
|
63
|
+
"type": "float",
|
64
|
+
"default": 0.0
|
65
|
+
}
|
66
|
+
]
|
67
|
+
},
|
68
|
+
{
|
69
|
+
"type": "record",
|
70
|
+
"name": "Record4",
|
71
|
+
"namespace": "com.flipp.content",
|
72
|
+
"fields": [
|
73
|
+
{
|
74
|
+
"name": "record4_id",
|
75
|
+
"type": "int",
|
76
|
+
"default": 0
|
77
|
+
}
|
78
|
+
]
|
79
|
+
},
|
80
|
+
"int",
|
81
|
+
{
|
82
|
+
"name": "test_array_of_strings",
|
83
|
+
"type": "array",
|
84
|
+
"default": [],
|
85
|
+
"items":"string"
|
86
|
+
}
|
87
|
+
],
|
88
|
+
"default": null
|
89
|
+
}
|
90
|
+
]
|
91
|
+
}
|
@@ -0,0 +1,185 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is autogenerated by Deimos, Do NOT modify
|
4
|
+
module Schemas
|
5
|
+
### Primary Schema Class ###
|
6
|
+
# Autogenerated Schema for Record at com.my-namespace.MySchemaWithUnionType
|
7
|
+
class MySchemaWithUnionType < Deimos::SchemaClass::Record
|
8
|
+
|
9
|
+
### Secondary Schema Classes ###
|
10
|
+
# Autogenerated Schema for Record at com.flipp.content.Record1
|
11
|
+
class Record1 < Deimos::SchemaClass::Record
|
12
|
+
|
13
|
+
### Attribute Accessors ###
|
14
|
+
# @return [Hash<String, Integer>]
|
15
|
+
attr_accessor :record1_map
|
16
|
+
# @return [Integer]
|
17
|
+
attr_accessor :record1_id
|
18
|
+
|
19
|
+
# @override
|
20
|
+
def initialize(record1_map: {},
|
21
|
+
record1_id: 0)
|
22
|
+
super
|
23
|
+
self.record1_map = record1_map
|
24
|
+
self.record1_id = record1_id
|
25
|
+
end
|
26
|
+
|
27
|
+
# @override
|
28
|
+
def schema
|
29
|
+
'Record1'
|
30
|
+
end
|
31
|
+
|
32
|
+
# @override
|
33
|
+
def namespace
|
34
|
+
'com.flipp.content'
|
35
|
+
end
|
36
|
+
|
37
|
+
# @override
|
38
|
+
def as_json(_opts={})
|
39
|
+
{
|
40
|
+
'record1_map' => @record1_map,
|
41
|
+
'record1_id' => @record1_id
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Autogenerated Schema for Record at com.flipp.content.Record2
|
47
|
+
class Record2 < Deimos::SchemaClass::Record
|
48
|
+
|
49
|
+
### Attribute Accessors ###
|
50
|
+
# @return [String]
|
51
|
+
attr_accessor :record2_id
|
52
|
+
|
53
|
+
# @override
|
54
|
+
def initialize(record2_id: "")
|
55
|
+
super
|
56
|
+
self.record2_id = record2_id
|
57
|
+
end
|
58
|
+
|
59
|
+
# @override
|
60
|
+
def schema
|
61
|
+
'Record2'
|
62
|
+
end
|
63
|
+
|
64
|
+
# @override
|
65
|
+
def namespace
|
66
|
+
'com.flipp.content'
|
67
|
+
end
|
68
|
+
|
69
|
+
# @override
|
70
|
+
def as_json(_opts={})
|
71
|
+
{
|
72
|
+
'record2_id' => @record2_id
|
73
|
+
}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Autogenerated Schema for Record at com.flipp.content.Record3
|
78
|
+
class Record3 < Deimos::SchemaClass::Record
|
79
|
+
|
80
|
+
### Attribute Accessors ###
|
81
|
+
# @return [Float]
|
82
|
+
attr_accessor :record3_id
|
83
|
+
|
84
|
+
# @override
|
85
|
+
def initialize(record3_id: 0.0)
|
86
|
+
super
|
87
|
+
self.record3_id = record3_id
|
88
|
+
end
|
89
|
+
|
90
|
+
# @override
|
91
|
+
def schema
|
92
|
+
'Record3'
|
93
|
+
end
|
94
|
+
|
95
|
+
# @override
|
96
|
+
def namespace
|
97
|
+
'com.flipp.content'
|
98
|
+
end
|
99
|
+
|
100
|
+
# @override
|
101
|
+
def as_json(_opts={})
|
102
|
+
{
|
103
|
+
'record3_id' => @record3_id
|
104
|
+
}
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Autogenerated Schema for Record at com.flipp.content.Record4
|
109
|
+
class Record4 < Deimos::SchemaClass::Record
|
110
|
+
|
111
|
+
### Attribute Accessors ###
|
112
|
+
# @return [Integer]
|
113
|
+
attr_accessor :record4_id
|
114
|
+
|
115
|
+
# @override
|
116
|
+
def initialize(record4_id: 0)
|
117
|
+
super
|
118
|
+
self.record4_id = record4_id
|
119
|
+
end
|
120
|
+
|
121
|
+
# @override
|
122
|
+
def schema
|
123
|
+
'Record4'
|
124
|
+
end
|
125
|
+
|
126
|
+
# @override
|
127
|
+
def namespace
|
128
|
+
'com.flipp.content'
|
129
|
+
end
|
130
|
+
|
131
|
+
# @override
|
132
|
+
def as_json(_opts={})
|
133
|
+
{
|
134
|
+
'record4_id' => @record4_id
|
135
|
+
}
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
### Attribute Readers ###
|
141
|
+
# @return [nil, Record1, Record2, Record3, Record4, Integer, Array<String>]
|
142
|
+
attr_reader :test_union_type
|
143
|
+
|
144
|
+
### Attribute Accessors ###
|
145
|
+
# @return [String]
|
146
|
+
attr_accessor :test_id
|
147
|
+
# @return [nil, Integer]
|
148
|
+
attr_accessor :test_long
|
149
|
+
|
150
|
+
### Attribute Writers ###
|
151
|
+
# @return [nil, Record1, Record2, Record3, Record4, Integer, Array<String>]
|
152
|
+
def test_union_type=(value)
|
153
|
+
@test_union_type = Record1.initialize_from_value(value)
|
154
|
+
end
|
155
|
+
|
156
|
+
# @override
|
157
|
+
def initialize(test_id: "",
|
158
|
+
test_long: nil,
|
159
|
+
test_union_type: nil)
|
160
|
+
super
|
161
|
+
self.test_id = test_id
|
162
|
+
self.test_long = test_long
|
163
|
+
self.test_union_type = test_union_type
|
164
|
+
end
|
165
|
+
|
166
|
+
# @override
|
167
|
+
def schema
|
168
|
+
'MySchemaWithUnionType'
|
169
|
+
end
|
170
|
+
|
171
|
+
# @override
|
172
|
+
def namespace
|
173
|
+
'com.my-namespace'
|
174
|
+
end
|
175
|
+
|
176
|
+
# @override
|
177
|
+
def as_json(_opts={})
|
178
|
+
{
|
179
|
+
'test_id' => @test_id,
|
180
|
+
'test_long' => @test_long,
|
181
|
+
'test_union_type' => @test_union_type&.as_json
|
182
|
+
}
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|