avro-gen-ruby 0.1.0
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 +7 -0
- data/.github/workflows/ci.yml +34 -0
- data/.github/workflows/release.yml +31 -0
- data/.gitignore +6 -0
- data/.rspec +1 -0
- data/.rubocop.yml +100 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +61 -0
- data/Rakefile +11 -0
- data/avro-gen-ruby.gemspec +32 -0
- data/lib/avro_gen/avro_parser.rb +64 -0
- data/lib/avro_gen/configuration.rb +60 -0
- data/lib/avro_gen/errors.rb +6 -0
- data/lib/avro_gen/generator/templates/schema_class.rb.tt +8 -0
- data/lib/avro_gen/generator/templates/schema_enum.rb.tt +13 -0
- data/lib/avro_gen/generator/templates/schema_record.rb.tt +102 -0
- data/lib/avro_gen/generator.rb +375 -0
- data/lib/avro_gen/railtie.rb +12 -0
- data/lib/avro_gen/schema_class/base.rb +62 -0
- data/lib/avro_gen/schema_class/enum.rb +48 -0
- data/lib/avro_gen/schema_class/record.rb +108 -0
- data/lib/avro_gen/schema_class.rb +62 -0
- data/lib/avro_gen/schema_field.rb +26 -0
- data/lib/avro_gen/schema_validator.rb +80 -0
- data/lib/avro_gen/upgrader.rb +43 -0
- data/lib/avro_gen/version.rb +5 -0
- data/lib/avro_gen.rb +18 -0
- data/lib/tasks/avro.rake +18 -0
- data/regenerate_test_schema_classes.rb +32 -0
- data/spec/generator_spec.rb +92 -0
- data/spec/my_schema_spec.rb +18 -0
- data/spec/my_schema_with_circular_reference_spec.rb +97 -0
- data/spec/my_schema_with_complex_types_spec.rb +235 -0
- data/spec/schema_validator_spec.rb +42 -0
- data/spec/schemas/com/my-namespace/Generated.avsc +77 -0
- data/spec/schemas/com/my-namespace/MyNestedSchema.avsc +62 -0
- data/spec/schemas/com/my-namespace/MySchema.avsc +18 -0
- data/spec/schemas/com/my-namespace/MySchemaCompound_key.avsc +18 -0
- data/spec/schemas/com/my-namespace/MySchemaId_key.avsc +12 -0
- data/spec/schemas/com/my-namespace/MySchemaWithBooleans.avsc +18 -0
- data/spec/schemas/com/my-namespace/MySchemaWithCircularReference.avsc +39 -0
- data/spec/schemas/com/my-namespace/MySchemaWithComplexTypes.avsc +120 -0
- data/spec/schemas/com/my-namespace/MySchemaWithDateTimes.avsc +33 -0
- data/spec/schemas/com/my-namespace/MySchemaWithId.avsc +28 -0
- data/spec/schemas/com/my-namespace/MySchemaWithTitle.avsc +22 -0
- data/spec/schemas/com/my-namespace/MySchemaWithUnionType.avsc +91 -0
- data/spec/schemas/com/my-namespace/MySchemaWithUniqueId.avsc +32 -0
- data/spec/schemas/com/my-namespace/MySchema_key.avsc +13 -0
- data/spec/schemas/com/my-namespace/Wibble.avsc +43 -0
- data/spec/schemas/com/my-namespace/Widget.avsc +27 -0
- data/spec/schemas/com/my-namespace/WidgetTheSecond.avsc +27 -0
- data/spec/schemas/com/my-namespace/WidgetTheThird.avsc +27 -0
- data/spec/schemas/com/my-namespace/my-suborg/MyLongNamespaceSchema.avsc +18 -0
- data/spec/schemas/com/my-namespace/request/CreateTopic.avsc +11 -0
- data/spec/schemas/com/my-namespace/request/Index.avsc +11 -0
- data/spec/schemas/com/my-namespace/request/UpdateRequest.avsc +11 -0
- data/spec/schemas/com/my-namespace/response/CreateTopic.avsc +11 -0
- data/spec/schemas/com/my-namespace/response/Index.avsc +11 -0
- data/spec/schemas/com/my-namespace/response/UpdateResponse.avsc +11 -0
- data/spec/schemas/my_namespace/generated.rb +164 -0
- data/spec/schemas/my_namespace/my_long_namespace_schema.rb +49 -0
- data/spec/schemas/my_namespace/my_nested_schema.rb +126 -0
- data/spec/schemas/my_namespace/my_schema.rb +62 -0
- data/spec/schemas/my_namespace/my_schema_compound_key.rb +42 -0
- data/spec/schemas/my_namespace/my_schema_id_key.rb +37 -0
- data/spec/schemas/my_namespace/my_schema_key.rb +37 -0
- data/spec/schemas/my_namespace/my_schema_with_boolean.rb +42 -0
- data/spec/schemas/my_namespace/my_schema_with_circular_reference.rb +84 -0
- data/spec/schemas/my_namespace/my_schema_with_complex_type.rb +241 -0
- data/spec/schemas/my_namespace/my_schema_with_date_time.rb +57 -0
- data/spec/schemas/my_namespace/my_schema_with_id.rb +52 -0
- data/spec/schemas/my_namespace/my_schema_with_title.rb +47 -0
- data/spec/schemas/my_namespace/my_schema_with_union_type.rb +205 -0
- data/spec/schemas/my_namespace/my_schema_with_unique_id.rb +57 -0
- data/spec/schemas/my_namespace/request/create_topic.rb +37 -0
- data/spec/schemas/my_namespace/request/index.rb +37 -0
- data/spec/schemas/my_namespace/request/update_request.rb +37 -0
- data/spec/schemas/my_namespace/response/create_topic.rb +37 -0
- data/spec/schemas/my_namespace/response/index.rb +37 -0
- data/spec/schemas/my_namespace/response/update_response.rb +37 -0
- data/spec/schemas/my_namespace/wibble.rb +77 -0
- data/spec/schemas/my_namespace/widget.rb +57 -0
- data/spec/schemas/my_namespace/widget_the_second.rb +57 -0
- data/spec/schemas/my_namespace/widget_the_third.rb +57 -0
- data/spec/snapshots/consumers-no-nest.snap +1740 -0
- data/spec/snapshots/consumers.snap +1720 -0
- data/spec/snapshots/my_nested_schema.snap +121 -0
- data/spec/snapshots/my_schema_with_boolean.snap +44 -0
- data/spec/snapshots/my_schema_with_circular_reference.snap +81 -0
- data/spec/snapshots/my_schema_with_complex_type.snap +236 -0
- data/spec/snapshots/my_schema_with_date_time.snap +59 -0
- data/spec/snapshots/my_schema_with_union_type.snap +207 -0
- data/spec/snapshots/namespace_folders.snap +1800 -0
- data/spec/snapshots/namespace_map.snap +1800 -0
- data/spec/spec_helper.rb +23 -0
- metadata +265 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
spec/app/lib/schema_classes/my_nested_schema.rb:
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# This file is autogenerated by AvroGen, Do NOT modify
|
|
5
|
+
module Schemas
|
|
6
|
+
### Primary Schema Class ###
|
|
7
|
+
# Autogenerated Schema for Record at com.my-namespace.MyNestedSchema
|
|
8
|
+
class MyNestedSchema < AvroGen::SchemaClass::Record
|
|
9
|
+
|
|
10
|
+
### Secondary Schema Classes ###
|
|
11
|
+
# Autogenerated Schema for Record at com.my-namespace.MyNestedRecord
|
|
12
|
+
class MyNestedRecord < AvroGen::SchemaClass::Record
|
|
13
|
+
|
|
14
|
+
### Attribute Accessors ###
|
|
15
|
+
# @return [Integer]
|
|
16
|
+
attr_accessor :some_int
|
|
17
|
+
# @return [Float]
|
|
18
|
+
attr_accessor :some_float
|
|
19
|
+
# @return [String]
|
|
20
|
+
attr_accessor :some_string
|
|
21
|
+
# @return [nil, Integer]
|
|
22
|
+
attr_accessor :some_optional_int
|
|
23
|
+
|
|
24
|
+
# @override
|
|
25
|
+
def initialize(_from_message: false, some_int: nil,
|
|
26
|
+
some_float: nil,
|
|
27
|
+
some_string: nil,
|
|
28
|
+
some_optional_int: nil)
|
|
29
|
+
@_from_message = _from_message
|
|
30
|
+
super
|
|
31
|
+
self.some_int = some_int
|
|
32
|
+
self.some_float = some_float
|
|
33
|
+
self.some_string = some_string
|
|
34
|
+
self.some_optional_int = some_optional_int
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @override
|
|
38
|
+
def schema
|
|
39
|
+
'MyNestedRecord'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @override
|
|
43
|
+
def namespace
|
|
44
|
+
'com.my-namespace'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# @override
|
|
48
|
+
def as_json(_opts={})
|
|
49
|
+
{
|
|
50
|
+
'some_int' => @some_int,
|
|
51
|
+
'some_float' => @some_float,
|
|
52
|
+
'some_string' => @some_string,
|
|
53
|
+
'some_optional_int' => @some_optional_int
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Attribute Readers ###
|
|
60
|
+
# @return [MyNestedRecord]
|
|
61
|
+
attr_reader :some_nested_record
|
|
62
|
+
# @return [nil, MyNestedRecord]
|
|
63
|
+
attr_reader :some_optional_record
|
|
64
|
+
|
|
65
|
+
### Attribute Accessors ###
|
|
66
|
+
# @return [String]
|
|
67
|
+
attr_accessor :test_id
|
|
68
|
+
# @return [Float]
|
|
69
|
+
attr_accessor :test_float
|
|
70
|
+
# @return [Array<String>]
|
|
71
|
+
attr_accessor :test_array
|
|
72
|
+
|
|
73
|
+
### Attribute Writers ###
|
|
74
|
+
# @return [MyNestedRecord]
|
|
75
|
+
def some_nested_record=(value)
|
|
76
|
+
@some_nested_record = MyNestedRecord.initialize_from_value(value, from_message: self._from_message)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# @return [nil, MyNestedRecord]
|
|
80
|
+
def some_optional_record=(value)
|
|
81
|
+
@some_optional_record = MyNestedRecord.initialize_from_value(value, from_message: self._from_message)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# @override
|
|
85
|
+
def initialize(_from_message: false, test_id: nil,
|
|
86
|
+
test_float: nil,
|
|
87
|
+
test_array: nil,
|
|
88
|
+
some_nested_record: nil,
|
|
89
|
+
some_optional_record: nil)
|
|
90
|
+
@_from_message = _from_message
|
|
91
|
+
super
|
|
92
|
+
self.test_id = test_id
|
|
93
|
+
self.test_float = test_float
|
|
94
|
+
self.test_array = test_array
|
|
95
|
+
self.some_nested_record = some_nested_record
|
|
96
|
+
self.some_optional_record = some_optional_record
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# @override
|
|
100
|
+
def schema
|
|
101
|
+
'MyNestedSchema'
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# @override
|
|
105
|
+
def namespace
|
|
106
|
+
'com.my-namespace'
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# @override
|
|
110
|
+
def as_json(_opts={})
|
|
111
|
+
{
|
|
112
|
+
'test_id' => @test_id,
|
|
113
|
+
'test_float' => @test_float,
|
|
114
|
+
'test_array' => @test_array,
|
|
115
|
+
'some_nested_record' => @some_nested_record&.as_json,
|
|
116
|
+
'some_optional_record' => @some_optional_record&.as_json
|
|
117
|
+
}
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
spec/app/lib/schema_classes/my_schema_with_boolean.rb:
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# This file is autogenerated by AvroGen, Do NOT modify
|
|
5
|
+
module Schemas
|
|
6
|
+
### Primary Schema Class ###
|
|
7
|
+
# Autogenerated Schema for Record at com.my-namespace.MySchemaWithBooleans
|
|
8
|
+
class MySchemaWithBoolean < AvroGen::SchemaClass::Record
|
|
9
|
+
|
|
10
|
+
### Attribute Accessors ###
|
|
11
|
+
# @return [String]
|
|
12
|
+
attr_accessor :test_id
|
|
13
|
+
# @return [Boolean]
|
|
14
|
+
attr_accessor :some_bool
|
|
15
|
+
|
|
16
|
+
# @override
|
|
17
|
+
def initialize(_from_message: false, test_id: nil,
|
|
18
|
+
some_bool: nil)
|
|
19
|
+
@_from_message = _from_message
|
|
20
|
+
super
|
|
21
|
+
self.test_id = test_id
|
|
22
|
+
self.some_bool = some_bool
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @override
|
|
26
|
+
def schema
|
|
27
|
+
'MySchemaWithBooleans'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @override
|
|
31
|
+
def namespace
|
|
32
|
+
'com.my-namespace'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @override
|
|
36
|
+
def as_json(_opts={})
|
|
37
|
+
{
|
|
38
|
+
'test_id' => @test_id,
|
|
39
|
+
'some_bool' => @some_bool
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
spec/app/lib/schema_classes/my_schema_with_circular_reference.rb:
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# This file is autogenerated by AvroGen, Do NOT modify
|
|
5
|
+
module Schemas
|
|
6
|
+
### Primary Schema Class ###
|
|
7
|
+
# Autogenerated Schema for Record at com.my-namespace.MySchemaWithCircularReference
|
|
8
|
+
class MySchemaWithCircularReference < AvroGen::SchemaClass::Record
|
|
9
|
+
|
|
10
|
+
### Secondary Schema Classes ###
|
|
11
|
+
# Autogenerated Schema for Record at com.my-namespace.Property
|
|
12
|
+
class Property < AvroGen::SchemaClass::Record
|
|
13
|
+
|
|
14
|
+
### Attribute Accessors ###
|
|
15
|
+
# @return [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
|
|
16
|
+
attr_accessor :property
|
|
17
|
+
|
|
18
|
+
# @override
|
|
19
|
+
def initialize(_from_message: false, property: nil)
|
|
20
|
+
@_from_message = _from_message
|
|
21
|
+
super
|
|
22
|
+
self.property = property
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @override
|
|
26
|
+
def schema
|
|
27
|
+
'Property'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @override
|
|
31
|
+
def namespace
|
|
32
|
+
'com.my-namespace'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @override
|
|
36
|
+
def as_json(_opts={})
|
|
37
|
+
{
|
|
38
|
+
'property' => @property
|
|
39
|
+
}
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Attribute Readers ###
|
|
45
|
+
# @return [Hash<String, Property>]
|
|
46
|
+
attr_reader :properties
|
|
47
|
+
|
|
48
|
+
### Attribute Writers ###
|
|
49
|
+
# @return [Hash<String, Property>]
|
|
50
|
+
def properties=(values)
|
|
51
|
+
@properties = values&.transform_values do |value|
|
|
52
|
+
Property.initialize_from_value(value, from_message: self._from_message)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# @override
|
|
57
|
+
def initialize(_from_message: false, properties: {})
|
|
58
|
+
@_from_message = _from_message
|
|
59
|
+
super
|
|
60
|
+
self.properties = properties
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# @override
|
|
64
|
+
def schema
|
|
65
|
+
'MySchemaWithCircularReference'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# @override
|
|
69
|
+
def namespace
|
|
70
|
+
'com.my-namespace'
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# @override
|
|
74
|
+
def as_json(_opts={})
|
|
75
|
+
{
|
|
76
|
+
'properties' => @properties.transform_values { |v| v&.as_json }
|
|
77
|
+
}
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
spec/app/lib/schema_classes/my_schema_with_complex_type.rb:
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# This file is autogenerated by AvroGen, Do NOT modify
|
|
5
|
+
module Schemas
|
|
6
|
+
### Primary Schema Class ###
|
|
7
|
+
# Autogenerated Schema for Record at com.my-namespace.MySchemaWithComplexTypes
|
|
8
|
+
class MySchemaWithComplexType < AvroGen::SchemaClass::Record
|
|
9
|
+
|
|
10
|
+
### Secondary Schema Classes ###
|
|
11
|
+
# Autogenerated Schema for Record at com.my-namespace.ARecord
|
|
12
|
+
class ARecord < AvroGen::SchemaClass::Record
|
|
13
|
+
|
|
14
|
+
### Attribute Accessors ###
|
|
15
|
+
# @return [String]
|
|
16
|
+
attr_accessor :a_record_field
|
|
17
|
+
|
|
18
|
+
# @override
|
|
19
|
+
def initialize(_from_message: false, a_record_field: nil)
|
|
20
|
+
@_from_message = _from_message
|
|
21
|
+
super
|
|
22
|
+
self.a_record_field = a_record_field
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# @override
|
|
26
|
+
def schema
|
|
27
|
+
'ARecord'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# @override
|
|
31
|
+
def namespace
|
|
32
|
+
'com.my-namespace'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @override
|
|
36
|
+
def as_json(_opts={})
|
|
37
|
+
{
|
|
38
|
+
'a_record_field' => @a_record_field
|
|
39
|
+
}
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Autogenerated Schema for Enum at com.my-namespace.AnEnum
|
|
44
|
+
class AnEnum < AvroGen::SchemaClass::Enum
|
|
45
|
+
# @override
|
|
46
|
+
def symbols
|
|
47
|
+
%w(sym1 sym2)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def sym1?
|
|
52
|
+
@value == 'sym1'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def sym2?
|
|
56
|
+
@value == 'sym2'
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Autogenerated Schema for Enum at com.my-namespace.AnotherEnum
|
|
62
|
+
class AnotherEnum < AvroGen::SchemaClass::Enum
|
|
63
|
+
# @override
|
|
64
|
+
def symbols
|
|
65
|
+
%w(sym3 sym4)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def sym3?
|
|
70
|
+
@value == 'sym3'
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def sym4?
|
|
74
|
+
@value == 'sym4'
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Autogenerated Schema for Enum at com.my-namespace.YetAnotherEnum
|
|
80
|
+
class YetAnotherEnum < AvroGen::SchemaClass::Enum
|
|
81
|
+
# @override
|
|
82
|
+
def symbols
|
|
83
|
+
%w(sym5 sym6)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def sym5?
|
|
88
|
+
@value == 'sym5'
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def sym6?
|
|
92
|
+
@value == 'sym6'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
### Attribute Readers ###
|
|
99
|
+
# @return [ARecord]
|
|
100
|
+
attr_reader :some_record
|
|
101
|
+
# @return [nil, ARecord]
|
|
102
|
+
attr_reader :some_optional_record
|
|
103
|
+
# @return [Array<ARecord>]
|
|
104
|
+
attr_reader :some_record_array
|
|
105
|
+
# @return [Hash<String, ARecord>]
|
|
106
|
+
attr_reader :some_record_map
|
|
107
|
+
# @return [Array<AnEnum>]
|
|
108
|
+
attr_reader :some_enum_array
|
|
109
|
+
# @return [nil, AnotherEnum]
|
|
110
|
+
attr_reader :some_optional_enum
|
|
111
|
+
# @return [YetAnotherEnum]
|
|
112
|
+
attr_reader :some_enum_with_default
|
|
113
|
+
|
|
114
|
+
### Attribute Accessors ###
|
|
115
|
+
# @return [String]
|
|
116
|
+
attr_accessor :test_id
|
|
117
|
+
# @return [String, nil]
|
|
118
|
+
attr_accessor :union_string
|
|
119
|
+
# @return [Float]
|
|
120
|
+
attr_accessor :test_float
|
|
121
|
+
# @return [Array<String>]
|
|
122
|
+
attr_accessor :test_string_array
|
|
123
|
+
# @return [Array<Integer>]
|
|
124
|
+
attr_accessor :test_int_array
|
|
125
|
+
# @return [Integer, nil]
|
|
126
|
+
attr_accessor :test_optional_int
|
|
127
|
+
# @return [Hash<String, Integer>]
|
|
128
|
+
attr_accessor :some_integer_map
|
|
129
|
+
|
|
130
|
+
### Attribute Writers ###
|
|
131
|
+
# @return [ARecord]
|
|
132
|
+
def some_record=(value)
|
|
133
|
+
@some_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# @return [nil, ARecord]
|
|
137
|
+
def some_optional_record=(value)
|
|
138
|
+
@some_optional_record = ARecord.initialize_from_value(value, from_message: self._from_message)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# @return [Array<ARecord>]
|
|
142
|
+
def some_record_array=(values)
|
|
143
|
+
@some_record_array = values&.map do |value|
|
|
144
|
+
ARecord.initialize_from_value(value, from_message: self._from_message)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# @return [Hash<String, ARecord>]
|
|
149
|
+
def some_record_map=(values)
|
|
150
|
+
@some_record_map = values&.transform_values do |value|
|
|
151
|
+
ARecord.initialize_from_value(value, from_message: self._from_message)
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# @return [Array<AnEnum>]
|
|
156
|
+
def some_enum_array=(values)
|
|
157
|
+
@some_enum_array = values&.map do |value|
|
|
158
|
+
AnEnum.initialize_from_value(value, from_message: self._from_message)
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# @return [nil, AnotherEnum]
|
|
163
|
+
def some_optional_enum=(value)
|
|
164
|
+
@some_optional_enum = AnotherEnum.initialize_from_value(value, from_message: self._from_message)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# @return [YetAnotherEnum]
|
|
168
|
+
def some_enum_with_default=(value)
|
|
169
|
+
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value, from_message: self._from_message)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# @override
|
|
173
|
+
def initialize(_from_message: false, test_id: nil,
|
|
174
|
+
union_string: "",
|
|
175
|
+
test_float: nil,
|
|
176
|
+
test_string_array: ["test"],
|
|
177
|
+
test_int_array: [123],
|
|
178
|
+
test_optional_int: 123,
|
|
179
|
+
some_integer_map: {"abc"=>123},
|
|
180
|
+
some_record: {"a_record_field"=>"Test String"},
|
|
181
|
+
some_optional_record: nil,
|
|
182
|
+
some_record_array: nil,
|
|
183
|
+
some_record_map: nil,
|
|
184
|
+
some_enum_array: nil,
|
|
185
|
+
some_optional_enum: nil,
|
|
186
|
+
some_enum_with_default: "sym6")
|
|
187
|
+
@_from_message = _from_message
|
|
188
|
+
super
|
|
189
|
+
self.test_id = test_id
|
|
190
|
+
self.union_string = union_string
|
|
191
|
+
self.test_float = test_float
|
|
192
|
+
self.test_string_array = test_string_array
|
|
193
|
+
self.test_int_array = test_int_array
|
|
194
|
+
self.test_optional_int = test_optional_int
|
|
195
|
+
self.some_integer_map = some_integer_map
|
|
196
|
+
self.some_record = some_record
|
|
197
|
+
self.some_optional_record = some_optional_record
|
|
198
|
+
self.some_record_array = some_record_array
|
|
199
|
+
self.some_record_map = some_record_map
|
|
200
|
+
self.some_enum_array = some_enum_array
|
|
201
|
+
self.some_optional_enum = some_optional_enum
|
|
202
|
+
self.some_enum_with_default = some_enum_with_default
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# @override
|
|
206
|
+
def schema
|
|
207
|
+
'MySchemaWithComplexTypes'
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# @override
|
|
211
|
+
def namespace
|
|
212
|
+
'com.my-namespace'
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# @override
|
|
216
|
+
def as_json(_opts={})
|
|
217
|
+
{
|
|
218
|
+
'test_id' => @test_id,
|
|
219
|
+
'union_string' => @union_string,
|
|
220
|
+
'test_float' => @test_float,
|
|
221
|
+
'test_string_array' => @test_string_array,
|
|
222
|
+
'test_int_array' => @test_int_array,
|
|
223
|
+
'test_optional_int' => @test_optional_int,
|
|
224
|
+
'some_integer_map' => @some_integer_map,
|
|
225
|
+
'some_record' => @some_record&.as_json,
|
|
226
|
+
'some_optional_record' => @some_optional_record&.as_json,
|
|
227
|
+
'some_record_array' => @some_record_array.map { |v| v&.as_json },
|
|
228
|
+
'some_record_map' => @some_record_map.transform_values { |v| v&.as_json },
|
|
229
|
+
'some_enum_array' => @some_enum_array.map { |v| v&.as_json },
|
|
230
|
+
'some_optional_enum' => @some_optional_enum&.as_json,
|
|
231
|
+
'some_enum_with_default' => @some_enum_with_default&.as_json
|
|
232
|
+
}
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
spec/app/lib/schema_classes/my_schema_with_date_time.rb:
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# This file is autogenerated by AvroGen, Do NOT modify
|
|
5
|
+
module Schemas
|
|
6
|
+
### Primary Schema Class ###
|
|
7
|
+
# Autogenerated Schema for Record at com.my-namespace.MySchemaWithDateTimes
|
|
8
|
+
class MySchemaWithDateTime < AvroGen::SchemaClass::Record
|
|
9
|
+
|
|
10
|
+
### Attribute Accessors ###
|
|
11
|
+
# @return [String]
|
|
12
|
+
attr_accessor :test_id
|
|
13
|
+
# @return [Integer, nil]
|
|
14
|
+
attr_accessor :updated_at
|
|
15
|
+
# @return [nil, Integer]
|
|
16
|
+
attr_accessor :some_int
|
|
17
|
+
# @return [nil, Integer]
|
|
18
|
+
attr_accessor :some_datetime_int
|
|
19
|
+
# @return [String]
|
|
20
|
+
attr_accessor :timestamp
|
|
21
|
+
|
|
22
|
+
# @override
|
|
23
|
+
def initialize(_from_message: false, test_id: nil,
|
|
24
|
+
updated_at: nil,
|
|
25
|
+
some_int: nil,
|
|
26
|
+
some_datetime_int: nil,
|
|
27
|
+
timestamp: nil)
|
|
28
|
+
@_from_message = _from_message
|
|
29
|
+
super
|
|
30
|
+
self.test_id = test_id
|
|
31
|
+
self.updated_at = updated_at
|
|
32
|
+
self.some_int = some_int
|
|
33
|
+
self.some_datetime_int = some_datetime_int
|
|
34
|
+
self.timestamp = timestamp
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @override
|
|
38
|
+
def schema
|
|
39
|
+
'MySchemaWithDateTimes'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# @override
|
|
43
|
+
def namespace
|
|
44
|
+
'com.my-namespace'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# @override
|
|
48
|
+
def as_json(_opts={})
|
|
49
|
+
{
|
|
50
|
+
'test_id' => @test_id,
|
|
51
|
+
'updated_at' => @updated_at,
|
|
52
|
+
'some_int' => @some_int,
|
|
53
|
+
'some_datetime_int' => @some_datetime_int,
|
|
54
|
+
'timestamp' => @timestamp
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|