deimos-ruby 1.13.0 → 1.13.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/deimos/schema_class/base.rb +17 -0
- data/lib/deimos/test_helpers.rb +1 -1
- data/lib/deimos/version.rb +1 -1
- data/lib/generators/deimos/active_record/templates/migration.rb.tt +5 -3
- data/lib/generators/deimos/active_record_generator.rb +1 -1
- data/lib/generators/deimos/schema_class_generator.rb +9 -4
- data/spec/generators/schema_class/my_schema_with_circular_reference_spec.rb +97 -0
- data/spec/generators/schema_class/my_schema_with_complex_types_spec.rb +4 -3
- data/spec/generators/schema_class_generator_spec.rb +26 -0
- data/spec/schema_classes/generated.rb +22 -22
- data/spec/schema_classes/my_schema_with_circular_reference.rb +74 -0
- data/spec/schema_classes/my_schema_with_complex_types.rb +34 -2
- data/spec/schemas/com/my-namespace/MySchemaWithCircularReference.avsc +39 -0
- data/spec/schemas/com/my-namespace/MySchemaWithComplexTypes.avsc +9 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59719a901339d9ebf5806a71e960fc68a7e75a1a217e6003215a42db04edb261
|
4
|
+
data.tar.gz: f9e8f274825a78298779061cf279b563d7ec40948e34ceff4458a51f51dea6b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62489d41c135b8141b45cf2a3b71717fc41bed0a22b26cfadd5ad22635d1f3a4ca770f7321cf5205159dd0a1f879ea6a9628623b3c5c3d9205a533d179ba7b52
|
7
|
+
data.tar.gz: 689f66152efe31e6b65c0eea5db5471c2a927708ca2bdcad9a859b32b85ecf1f789efefbee71059d9351c2b7a332b90be093330fd3e5be375d3c0a92b44c7837
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## UNRELEASED
|
9
9
|
|
10
|
+
- Some cleanup on the active_record generator
|
11
|
+
- Fix crash with `test_consume_message` when using schema classes
|
12
|
+
- Add `[]=` and `merge` methods on the base schema class
|
13
|
+
|
14
|
+
# 1.13.2 - 2022-04-07
|
15
|
+
|
16
|
+
- Fix an issue with generating schema classes for schemas containing an enum with default value
|
17
|
+
|
18
|
+
# 1.13.1 - 2022-04-06
|
19
|
+
|
20
|
+
- Fix circular reference schema generation
|
21
|
+
|
10
22
|
# 1.13.0 - 2022-03-30
|
11
23
|
|
12
24
|
- Pass the Deimos logger to `AvroTurf::Messaging` for consistent logging
|
@@ -29,6 +29,23 @@ module Deimos
|
|
29
29
|
raise NotImplementedError
|
30
30
|
end
|
31
31
|
|
32
|
+
# @param key [String|Symbol]
|
33
|
+
# @param val [Object]
|
34
|
+
def []=(key, val)
|
35
|
+
self.send("#{key}=", val)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Merge a hash or an identical schema object with this one and return a new object.
|
39
|
+
# @param other_hash [Hash|SchemaClasses::Base]
|
40
|
+
# @return [SchemaClasses::Base]
|
41
|
+
def merge(other_hash)
|
42
|
+
obj = self.class.new(**self.to_h.symbolize_keys)
|
43
|
+
other_hash.to_h.each do |k, v|
|
44
|
+
obj.send("#{k}=", v)
|
45
|
+
end
|
46
|
+
obj
|
47
|
+
end
|
48
|
+
|
32
49
|
# :nodoc:
|
33
50
|
def ==(other)
|
34
51
|
comparison = other
|
data/lib/deimos/test_helpers.rb
CHANGED
@@ -188,7 +188,7 @@ module Deimos
|
|
188
188
|
&block)
|
189
189
|
raise 'Cannot have both call_original and be given a block!' if call_original && block_given?
|
190
190
|
|
191
|
-
payload
|
191
|
+
payload.stringify_keys! if payload.respond_to?(:stringify_keys!)
|
192
192
|
handler_class = if handler_class_or_topic.is_a?(String)
|
193
193
|
_get_handler_class_from_topic(handler_class_or_topic)
|
194
194
|
else
|
data/lib/deimos/version.rb
CHANGED
@@ -6,7 +6,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
|
|
6
6
|
end
|
7
7
|
create_table :<%= table_name %> do |t|
|
8
8
|
<%- fields.each do |key| -%>
|
9
|
-
<%- next if %w(id message_id timestamp).include?(key.name) -%>
|
9
|
+
<%- next if %w(id message_id timestamp updated_at created_at).include?(key.name) -%>
|
10
10
|
<%- sql_type = schema_base.sql_type(key)
|
11
11
|
if %w(record array map).include?(sql_type)
|
12
12
|
conn = ActiveRecord::Base.connection
|
@@ -15,9 +15,11 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
|
|
15
15
|
-%>
|
16
16
|
t.<%= sql_type %> :<%= key.name %>
|
17
17
|
<%- end -%>
|
18
|
-
end
|
19
18
|
|
20
|
-
|
19
|
+
t.timestamps
|
20
|
+
|
21
|
+
# TODO add indexes as necessary
|
22
|
+
end
|
21
23
|
end
|
22
24
|
|
23
25
|
def down
|
@@ -72,7 +72,7 @@ module Deimos
|
|
72
72
|
# :nodoc:
|
73
73
|
def generate
|
74
74
|
migration_template('migration.rb', "db/migrate/create_#{table_name.underscore}.rb")
|
75
|
-
template('model.rb', "app/models/#{table_name.underscore}.rb")
|
75
|
+
template('model.rb', "app/models/#{table_name.underscore.singularize}.rb")
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -63,7 +63,7 @@ module Deimos
|
|
63
63
|
elsif schema.respond_to?(:items)
|
64
64
|
[schema.items]
|
65
65
|
elsif schema.respond_to?(:schemas)
|
66
|
-
schema.schemas
|
66
|
+
schema.schemas.reject { |s| s.class == Avro::Schema::PrimitiveSchema }
|
67
67
|
else
|
68
68
|
[]
|
69
69
|
end
|
@@ -73,17 +73,22 @@ module Deimos
|
|
73
73
|
# @return [Array<Avro::Schema::NamedSchema>]
|
74
74
|
def collect_all_schemas(schemas)
|
75
75
|
schemas.dup.each do |schema|
|
76
|
+
next if @discovered_schemas.include?(schema)
|
77
|
+
|
78
|
+
@discovered_schemas << schema
|
76
79
|
schemas.concat(collect_all_schemas(child_schemas(schema)))
|
77
80
|
end
|
81
|
+
|
78
82
|
schemas.select { |s| s.respond_to?(:name) }.uniq
|
79
83
|
end
|
80
84
|
|
81
85
|
# @param schema_base [Deimos::SchemaBackends::Base]
|
82
86
|
# @param key_schema_base[Avro::Schema::NamedSchema]
|
83
87
|
def generate_class_from_schema_base(schema_base, key_schema_base: nil)
|
88
|
+
@discovered_schemas = Set.new
|
84
89
|
schemas = collect_all_schemas(schema_base.schema_store.schemas.values)
|
85
90
|
|
86
|
-
sub_schemas = schemas.reject { |s| s.name == schema_base.schema }
|
91
|
+
sub_schemas = schemas.reject { |s| s.name == schema_base.schema }.sort_by(&:name)
|
87
92
|
@sub_schema_templates = sub_schemas.map do |schema|
|
88
93
|
_generate_class_template_from_schema(schema)
|
89
94
|
end
|
@@ -201,8 +206,8 @@ module Deimos
|
|
201
206
|
return ' nil' if default == :no_default || default.nil? || IGNORE_DEFAULTS.include?(field.name)
|
202
207
|
|
203
208
|
case field.type.type_sym
|
204
|
-
when :string
|
205
|
-
"
|
209
|
+
when :string, :enum
|
210
|
+
" \"#{default}\""
|
206
211
|
when :record
|
207
212
|
schema_name = Deimos::SchemaBackends::AvroBase.schema_classname(field.type)
|
208
213
|
class_instance = Utils::SchemaClass.instance(field.default, schema_name)
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# For testing the generated class.
|
4
|
+
RSpec.describe Schemas::MySchemaWithCircularReference do
|
5
|
+
let(:payload_hash) do
|
6
|
+
{
|
7
|
+
properties: {
|
8
|
+
a_boolean: {
|
9
|
+
property: true
|
10
|
+
},
|
11
|
+
an_integer: {
|
12
|
+
property: 1
|
13
|
+
},
|
14
|
+
a_float: {
|
15
|
+
property: 4.5
|
16
|
+
},
|
17
|
+
a_string: {
|
18
|
+
property: 'string'
|
19
|
+
},
|
20
|
+
an_array: {
|
21
|
+
property: [1, 2, 3]
|
22
|
+
},
|
23
|
+
an_hash: {
|
24
|
+
property: {
|
25
|
+
a_key: 'a_value'
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'class initialization' do
|
33
|
+
it 'should initialize the class from keyword arguments' do
|
34
|
+
klass = described_class.new(properties: payload_hash[:properties])
|
35
|
+
expect(klass).to be_instance_of(described_class)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should initialize the class from a hash with symbols as keys' do
|
39
|
+
klass = described_class.new(**payload_hash)
|
40
|
+
expect(klass).to be_instance_of(described_class)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should initialize the class when missing attributes' do
|
44
|
+
payload_hash.delete(:properties)
|
45
|
+
klass = described_class.new(**payload_hash)
|
46
|
+
expect(klass).to be_instance_of(described_class)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'base class methods' do
|
52
|
+
let(:klass) do
|
53
|
+
described_class.new(**payload_hash)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should return the name of the schema and namespace' do
|
57
|
+
expect(klass.schema).to eq('MySchemaWithCircularReference')
|
58
|
+
expect(klass.namespace).to eq('com.my-namespace')
|
59
|
+
expect(klass.full_schema).to eq('com.my-namespace.MySchemaWithCircularReference')
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should return a json version of the payload' do
|
63
|
+
described_class.new(**payload_hash)
|
64
|
+
payload_h = {
|
65
|
+
'properties' => {
|
66
|
+
'a_boolean' => {
|
67
|
+
'property' => true
|
68
|
+
},
|
69
|
+
'an_integer' => {
|
70
|
+
'property' => 1
|
71
|
+
},
|
72
|
+
'a_float' => {
|
73
|
+
'property' => 4.5
|
74
|
+
},
|
75
|
+
'a_string' => {
|
76
|
+
'property' => 'string'
|
77
|
+
},
|
78
|
+
'an_array' => {
|
79
|
+
'property' => [1, 2, 3]
|
80
|
+
},
|
81
|
+
'an_hash' => {
|
82
|
+
'property' => {
|
83
|
+
'a_key' => 'a_value'
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
expect(klass.as_json).to eq(payload_h)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should return a JSON string of the payload' do
|
93
|
+
s = '{"properties":{"a_boolean":{"property":true},"an_integer":{"property":1},"a_float":{"property":4.5},"a_string":{"property":"string"},"an_array":{"property":[1,2,3]},"an_hash":{"property":{"a_key":"a_value"}}}}'
|
94
|
+
expect(klass.to_json).to eq(s)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -57,7 +57,7 @@ RSpec.describe Schemas::MySchemaWithComplexTypes do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
let(:schema_fields) do
|
60
|
-
%w(test_id test_float test_int_array test_optional_int test_string_array some_integer_map some_record some_optional_record some_record_array some_record_map some_enum_array some_optional_enum)
|
60
|
+
%w(test_id test_float test_int_array test_optional_int test_string_array some_integer_map some_record some_optional_record some_record_array some_record_map some_enum_array some_optional_enum some_enum_with_default)
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'should return the name of the schema and namespace' do
|
@@ -90,14 +90,15 @@ RSpec.describe Schemas::MySchemaWithComplexTypes do
|
|
90
90
|
'record_1' => { 'a_record_field' => 'field 5' },
|
91
91
|
'record_2' => { 'a_record_field' => 'field 6' }
|
92
92
|
},
|
93
|
-
'some_enum_array' => %w(sym1 sym2)
|
93
|
+
'some_enum_array' => %w(sym1 sym2),
|
94
|
+
'some_enum_with_default' => 'sym6'
|
94
95
|
}
|
95
96
|
|
96
97
|
expect(klass.as_json).to eq(payload_h)
|
97
98
|
end
|
98
99
|
|
99
100
|
it 'should return a JSON string of the payload' do
|
100
|
-
s = '{"test_id":"test id","test_float":1.2,"test_string_array":["abc","def"],"test_int_array":[123,456],"test_optional_int":123,"some_integer_map":{"int_1":1,"int_2":2},"some_record":{"a_record_field":"field 1"},"some_optional_record":{"a_record_field":"field 2"},"some_record_array":[{"a_record_field":"field 3"},{"a_record_field":"field 4"}],"some_record_map":{"record_1":{"a_record_field":"field 5"},"record_2":{"a_record_field":"field 6"}},"some_enum_array":["sym1","sym2"],"some_optional_enum":null}'
|
101
|
+
s = '{"test_id":"test id","test_float":1.2,"test_string_array":["abc","def"],"test_int_array":[123,456],"test_optional_int":123,"some_integer_map":{"int_1":1,"int_2":2},"some_record":{"a_record_field":"field 1"},"some_optional_record":{"a_record_field":"field 2"},"some_record_array":[{"a_record_field":"field 3"},{"a_record_field":"field 4"}],"some_record_map":{"record_1":{"a_record_field":"field 5"},"record_2":{"a_record_field":"field 6"}},"some_enum_array":["sym1","sym2"],"some_optional_enum":null,"some_enum_with_default":"sym6"}'
|
101
102
|
expect(klass.to_json).to eq(s)
|
102
103
|
end
|
103
104
|
end
|
@@ -73,6 +73,32 @@ RSpec.describe Deimos::Generators::SchemaClassGenerator do
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
+
context 'with a Consumers Schema with a circular reference' do
|
77
|
+
before(:each) do
|
78
|
+
Deimos.configure do
|
79
|
+
consumer do
|
80
|
+
class_name 'ConsumerTest::MyConsumer'
|
81
|
+
topic 'MyTopic'
|
82
|
+
schema 'MySchemaWithCircularReference'
|
83
|
+
namespace 'com.my-namespace'
|
84
|
+
key_config field: :a_string
|
85
|
+
end
|
86
|
+
end
|
87
|
+
described_class.start
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should generate the correct number of classes' do
|
91
|
+
expect(files.length).to eq(1)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should generate a schema class for my_schema_with_circular_reference' do
|
95
|
+
generated_path = files.select { |f| f =~ /my_schema_with_circular_reference/ }.first
|
96
|
+
expected_path = expected_files.select { |f| f =~ /my_schema_with_circular_reference/ }.first
|
97
|
+
|
98
|
+
expect(File.read(generated_path)).to eq(File.read(expected_path))
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
76
102
|
context 'with a Producers Schema and a Key' do
|
77
103
|
before(:each) do
|
78
104
|
Deimos.configure do
|
@@ -3,28 +3,6 @@
|
|
3
3
|
# This file is autogenerated by Deimos, Do NOT modify
|
4
4
|
module Schemas
|
5
5
|
### Secondary Schema Classes ###
|
6
|
-
# Autogenerated Schema for Enum at com.my-namespace.AnEnum
|
7
|
-
class AnEnum < Deimos::SchemaClass::Enum
|
8
|
-
# @return ['sym1', 'sym2']
|
9
|
-
attr_accessor :an_enum
|
10
|
-
|
11
|
-
# :nodoc:
|
12
|
-
def initialize(an_enum)
|
13
|
-
super
|
14
|
-
self.an_enum = an_enum
|
15
|
-
end
|
16
|
-
|
17
|
-
# @override
|
18
|
-
def symbols
|
19
|
-
%w(sym1 sym2)
|
20
|
-
end
|
21
|
-
|
22
|
-
# @override
|
23
|
-
def to_h
|
24
|
-
@an_enum
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
6
|
# Autogenerated Schema for Record at com.my-namespace.ARecord
|
29
7
|
class ARecord < Deimos::SchemaClass::Record
|
30
8
|
### Attribute Accessors ###
|
@@ -55,6 +33,28 @@ module Schemas
|
|
55
33
|
end
|
56
34
|
end
|
57
35
|
|
36
|
+
# Autogenerated Schema for Enum at com.my-namespace.AnEnum
|
37
|
+
class AnEnum < Deimos::SchemaClass::Enum
|
38
|
+
# @return ['sym1', 'sym2']
|
39
|
+
attr_accessor :an_enum
|
40
|
+
|
41
|
+
# :nodoc:
|
42
|
+
def initialize(an_enum)
|
43
|
+
super
|
44
|
+
self.an_enum = an_enum
|
45
|
+
end
|
46
|
+
|
47
|
+
# @override
|
48
|
+
def symbols
|
49
|
+
%w(sym1 sym2)
|
50
|
+
end
|
51
|
+
|
52
|
+
# @override
|
53
|
+
def to_h
|
54
|
+
@an_enum
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
58
|
### Primary Schema Class ###
|
59
59
|
# Autogenerated Schema for Record at com.my-namespace.Generated
|
60
60
|
class Generated < Deimos::SchemaClass::Record
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This file is autogenerated by Deimos, Do NOT modify
|
4
|
+
module Schemas
|
5
|
+
### Secondary Schema Classes ###
|
6
|
+
# Autogenerated Schema for Record at com.my-namespace.Property
|
7
|
+
class Property < Deimos::SchemaClass::Record
|
8
|
+
### Attribute Accessors ###
|
9
|
+
# @param value [Boolean, Integer, Integer, Float, Float, String, Array<Property>, Hash<String, Property>]
|
10
|
+
attr_accessor :property
|
11
|
+
|
12
|
+
# @override
|
13
|
+
def initialize(property: nil)
|
14
|
+
super
|
15
|
+
self.property = property
|
16
|
+
end
|
17
|
+
|
18
|
+
# @override
|
19
|
+
def schema
|
20
|
+
'Property'
|
21
|
+
end
|
22
|
+
|
23
|
+
# @override
|
24
|
+
def namespace
|
25
|
+
'com.my-namespace'
|
26
|
+
end
|
27
|
+
|
28
|
+
# @override
|
29
|
+
def to_h
|
30
|
+
{
|
31
|
+
'property' => @property
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
### Primary Schema Class ###
|
37
|
+
# Autogenerated Schema for Record at com.my-namespace.MySchemaWithCircularReference
|
38
|
+
class MySchemaWithCircularReference < Deimos::SchemaClass::Record
|
39
|
+
### Attribute Readers ###
|
40
|
+
# @return [Hash<String, Property>]
|
41
|
+
attr_reader :properties
|
42
|
+
|
43
|
+
### Attribute Writers ###
|
44
|
+
# @param values [Hash<String, Property>]
|
45
|
+
def properties=(values)
|
46
|
+
@properties = values.transform_values do |value|
|
47
|
+
Property.initialize_from_value(value)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# @override
|
52
|
+
def initialize(properties: {})
|
53
|
+
super
|
54
|
+
self.properties = properties
|
55
|
+
end
|
56
|
+
|
57
|
+
# @override
|
58
|
+
def schema
|
59
|
+
'MySchemaWithCircularReference'
|
60
|
+
end
|
61
|
+
|
62
|
+
# @override
|
63
|
+
def namespace
|
64
|
+
'com.my-namespace'
|
65
|
+
end
|
66
|
+
|
67
|
+
# @override
|
68
|
+
def to_h
|
69
|
+
{
|
70
|
+
'properties' => @properties.transform_values { |v| v&.to_h }
|
71
|
+
}
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -77,6 +77,28 @@ module Schemas
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
# Autogenerated Schema for Enum at com.my-namespace.YetAnotherEnum
|
81
|
+
class YetAnotherEnum < Deimos::SchemaClass::Enum
|
82
|
+
# @return ['sym5', 'sym6']
|
83
|
+
attr_accessor :yet_another_enum
|
84
|
+
|
85
|
+
# :nodoc:
|
86
|
+
def initialize(yet_another_enum)
|
87
|
+
super
|
88
|
+
self.yet_another_enum = yet_another_enum
|
89
|
+
end
|
90
|
+
|
91
|
+
# @override
|
92
|
+
def symbols
|
93
|
+
%w(sym5 sym6)
|
94
|
+
end
|
95
|
+
|
96
|
+
# @override
|
97
|
+
def to_h
|
98
|
+
@yet_another_enum
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
80
102
|
### Primary Schema Class ###
|
81
103
|
# Autogenerated Schema for Record at com.my-namespace.MySchemaWithComplexTypes
|
82
104
|
class MySchemaWithComplexTypes < Deimos::SchemaClass::Record
|
@@ -93,6 +115,8 @@ module Schemas
|
|
93
115
|
attr_reader :some_enum_array
|
94
116
|
# @return [nil, AnotherEnum]
|
95
117
|
attr_reader :some_optional_enum
|
118
|
+
# @return [YetAnotherEnum]
|
119
|
+
attr_reader :some_enum_with_default
|
96
120
|
|
97
121
|
### Attribute Accessors ###
|
98
122
|
# @param value [String]
|
@@ -145,6 +169,11 @@ module Schemas
|
|
145
169
|
@some_optional_enum = AnotherEnum.initialize_from_value(value)
|
146
170
|
end
|
147
171
|
|
172
|
+
# @param value [YetAnotherEnum]
|
173
|
+
def some_enum_with_default=(value)
|
174
|
+
@some_enum_with_default = YetAnotherEnum.initialize_from_value(value)
|
175
|
+
end
|
176
|
+
|
148
177
|
# @override
|
149
178
|
def initialize(test_id: nil,
|
150
179
|
test_float: nil,
|
@@ -157,7 +186,8 @@ module Schemas
|
|
157
186
|
some_record_array: nil,
|
158
187
|
some_record_map: nil,
|
159
188
|
some_enum_array: nil,
|
160
|
-
some_optional_enum: nil
|
189
|
+
some_optional_enum: nil,
|
190
|
+
some_enum_with_default: "sym6")
|
161
191
|
super
|
162
192
|
self.test_id = test_id
|
163
193
|
self.test_float = test_float
|
@@ -171,6 +201,7 @@ module Schemas
|
|
171
201
|
self.some_record_map = some_record_map
|
172
202
|
self.some_enum_array = some_enum_array
|
173
203
|
self.some_optional_enum = some_optional_enum
|
204
|
+
self.some_enum_with_default = some_enum_with_default
|
174
205
|
end
|
175
206
|
|
176
207
|
# @override
|
@@ -197,7 +228,8 @@ module Schemas
|
|
197
228
|
'some_record_array' => @some_record_array.map { |v| v&.to_h },
|
198
229
|
'some_record_map' => @some_record_map.transform_values { |v| v&.to_h },
|
199
230
|
'some_enum_array' => @some_enum_array.map { |v| v&.to_h },
|
200
|
-
'some_optional_enum' => @some_optional_enum&.to_h
|
231
|
+
'some_optional_enum' => @some_optional_enum&.to_h,
|
232
|
+
'some_enum_with_default' => @some_enum_with_default&.to_h
|
201
233
|
}
|
202
234
|
end
|
203
235
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"namespace": "com.my-namespace",
|
3
|
+
"name": "MySchemaWithCircularReference",
|
4
|
+
"type": "record",
|
5
|
+
"fields": [
|
6
|
+
{
|
7
|
+
"default": {},
|
8
|
+
"name": "properties",
|
9
|
+
"type": {
|
10
|
+
"type": "map",
|
11
|
+
"values": {
|
12
|
+
"fields": [
|
13
|
+
{
|
14
|
+
"name": "property",
|
15
|
+
"type": [
|
16
|
+
"boolean",
|
17
|
+
"int",
|
18
|
+
"long",
|
19
|
+
"float",
|
20
|
+
"double",
|
21
|
+
"string",
|
22
|
+
{
|
23
|
+
"items": "Property",
|
24
|
+
"type": "array"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"type": "map",
|
28
|
+
"values": "Property"
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
],
|
33
|
+
"name": "Property",
|
34
|
+
"type": "record"
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
]
|
39
|
+
}
|
@@ -101,6 +101,15 @@
|
|
101
101
|
"symbols": ["sym3", "sym4"]
|
102
102
|
}
|
103
103
|
]
|
104
|
+
},
|
105
|
+
{
|
106
|
+
"name": "some_enum_with_default",
|
107
|
+
"default": "sym6",
|
108
|
+
"type": {
|
109
|
+
"type": "enum",
|
110
|
+
"name": "YetAnotherEnum",
|
111
|
+
"symbols": ["sym5", "sym6"]
|
112
|
+
}
|
104
113
|
}
|
105
114
|
]
|
106
115
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deimos-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.13.
|
4
|
+
version: 1.13.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Orner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: avro_turf
|
@@ -463,6 +463,7 @@ files:
|
|
463
463
|
- spec/consumer_spec.rb
|
464
464
|
- spec/deimos_spec.rb
|
465
465
|
- spec/generators/active_record_generator_spec.rb
|
466
|
+
- spec/generators/schema_class/my_schema_with_circular_reference_spec.rb
|
466
467
|
- spec/generators/schema_class/my_schema_with_complex_types_spec.rb
|
467
468
|
- spec/generators/schema_class_generator_spec.rb
|
468
469
|
- spec/handlers/my_batch_consumer.rb
|
@@ -484,12 +485,14 @@ files:
|
|
484
485
|
- spec/schema_classes/my_nested_schema.rb
|
485
486
|
- spec/schema_classes/my_schema.rb
|
486
487
|
- spec/schema_classes/my_schema_key.rb
|
488
|
+
- spec/schema_classes/my_schema_with_circular_reference.rb
|
487
489
|
- spec/schema_classes/my_schema_with_complex_types.rb
|
488
490
|
- spec/schemas/com/my-namespace/Generated.avsc
|
489
491
|
- spec/schemas/com/my-namespace/MyNestedSchema.avsc
|
490
492
|
- spec/schemas/com/my-namespace/MySchema.avsc
|
491
493
|
- spec/schemas/com/my-namespace/MySchemaCompound_key.avsc
|
492
494
|
- spec/schemas/com/my-namespace/MySchemaWithBooleans.avsc
|
495
|
+
- spec/schemas/com/my-namespace/MySchemaWithCircularReference.avsc
|
493
496
|
- spec/schemas/com/my-namespace/MySchemaWithComplexTypes.avsc
|
494
497
|
- spec/schemas/com/my-namespace/MySchemaWithDateTimes.avsc
|
495
498
|
- spec/schemas/com/my-namespace/MySchemaWithId.avsc
|
@@ -554,6 +557,7 @@ test_files:
|
|
554
557
|
- spec/consumer_spec.rb
|
555
558
|
- spec/deimos_spec.rb
|
556
559
|
- spec/generators/active_record_generator_spec.rb
|
560
|
+
- spec/generators/schema_class/my_schema_with_circular_reference_spec.rb
|
557
561
|
- spec/generators/schema_class/my_schema_with_complex_types_spec.rb
|
558
562
|
- spec/generators/schema_class_generator_spec.rb
|
559
563
|
- spec/handlers/my_batch_consumer.rb
|
@@ -575,12 +579,14 @@ test_files:
|
|
575
579
|
- spec/schema_classes/my_nested_schema.rb
|
576
580
|
- spec/schema_classes/my_schema.rb
|
577
581
|
- spec/schema_classes/my_schema_key.rb
|
582
|
+
- spec/schema_classes/my_schema_with_circular_reference.rb
|
578
583
|
- spec/schema_classes/my_schema_with_complex_types.rb
|
579
584
|
- spec/schemas/com/my-namespace/Generated.avsc
|
580
585
|
- spec/schemas/com/my-namespace/MyNestedSchema.avsc
|
581
586
|
- spec/schemas/com/my-namespace/MySchema.avsc
|
582
587
|
- spec/schemas/com/my-namespace/MySchemaCompound_key.avsc
|
583
588
|
- spec/schemas/com/my-namespace/MySchemaWithBooleans.avsc
|
589
|
+
- spec/schemas/com/my-namespace/MySchemaWithCircularReference.avsc
|
584
590
|
- spec/schemas/com/my-namespace/MySchemaWithComplexTypes.avsc
|
585
591
|
- spec/schemas/com/my-namespace/MySchemaWithDateTimes.avsc
|
586
592
|
- spec/schemas/com/my-namespace/MySchemaWithId.avsc
|