diff --git a/CHANGELOG.md b/CHANGELOG.md index 5be8e4c0..4d5088f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Feature: `should_consume?` method accepts BatchRecord associations - Feature: Reintroduce `filter_records` for bulk filtering of records prior to insertion - Feature: Return valid and invalid records saved during consumption for further processing in `batch_consumption.valid_records` and `batch_consumption.invalid_records` ActiveSupport Notifications +- Feature: Rename configuration option `generate_namespace_folders` to `use_full_namespace`. This will now use the entire namespace when generating schema classes +- Feature: Add configuration option `schema_namespace_map` to enable full control over the namespace for generated schema classes. Requires `use_full_namespace` # 1.22.5 - 2023-07-18 - Fix: Fixed buffer overflow crash with DB producer. diff --git a/docs/CONFIGURATION.md b/docs/CONFIGURATION.md index 728d947d..115c5463 100644 --- a/docs/CONFIGURATION.md +++ b/docs/CONFIGURATION.md @@ -210,7 +210,8 @@ schema.path|nil|Local path to find your schemas. schema.use_schema_classes|false|Set this to true to use generated schema classes in your application. schema.generated_class_path|`app/lib/schema_classes`|Local path to generated schema classes. schema.nest_child_schemas|false|Set to true to nest subschemas within the generated class for the parent schema. -schema.generate_namespace_folders|false|Set to true to generate folders for schemas matching the last part of the namespace. +schema.use_full_namespace|false|Set to true to generate folders for schemas matching the full namespace. +schema.schema_namespace_map|{}|A map of namespace prefixes to base module name(s). Example: { 'com.mycompany.suborg' => ['SchemaClasses'] }. Requires `use_full_namespace` to be true. ## Database Producer Configuration diff --git a/lib/deimos/config/configuration.rb b/lib/deimos/config/configuration.rb index c2b2634f..1f1fad0e 100644 --- a/lib/deimos/config/configuration.rb +++ b/lib/deimos/config/configuration.rb @@ -380,7 +380,13 @@ def self.configure_producer_or_consumer(kafka_config) # Set to true to generate folders matching the last part of the schema namespace. # @return [Boolean] - setting :generate_namespace_folders, false + setting :use_full_namespace, false + + # Use this option to reduce nesting when using use_full_namespace. + # For example: { 'com.mycompany.suborg' => 'SchemaClasses' } + # would replace a prefixed with the given key with the module name SchemaClasses. + # @return [Hash] + setting :schema_namespace_map, {} end # The configured metrics provider. diff --git a/lib/deimos/utils/schema_class.rb b/lib/deimos/utils/schema_class.rb index 220a507a..45093a46 100644 --- a/lib/deimos/utils/schema_class.rb +++ b/lib/deimos/utils/schema_class.rb @@ -10,10 +10,25 @@ class << self # @return [Array] def modules_for(namespace) modules = ['Schemas'] - namespace_folder = namespace.split('.').last - if Deimos.config.schema.generate_namespace_folders && namespace_folder - modules.push(namespace_folder.underscore.classify) + namespace_override = nil + module_namespace = namespace + + if Deimos.config.schema.use_full_namespace + if Deimos.config.schema.schema_namespace_map.present? + namespace_keys = Deimos.config.schema.schema_namespace_map.keys.sort_by { |k| -k.length } + namespace_override = namespace_keys.find { |k| module_namespace.include?(k) } + end + + if namespace_override.present? + # override default module + modules = Array(Deimos.config.schema.schema_namespace_map[namespace_override]) + module_namespace = module_namespace.gsub(/#{namespace_override}\.?/, '') + end + + namespace_folders = module_namespace.split('.').map { |f| f.underscore.camelize } + modules.concat(namespace_folders) if namespace_folders.any? end + modules end diff --git a/lib/generators/deimos/schema_class_generator.rb b/lib/generators/deimos/schema_class_generator.rb index 0e30541e..93b58567 100644 --- a/lib/generators/deimos/schema_class_generator.rb +++ b/lib/generators/deimos/schema_class_generator.rb @@ -121,9 +121,16 @@ def write_file(schema, key_config) @main_class_definition = class_template file_prefix = schema.name.underscore.singularize - if Deimos.config.schema.generate_namespace_folders - file_prefix = "#{@modules.last.underscore.singularize}/#{file_prefix}" + if Deimos.config.schema.use_full_namespace + # Use entire namespace for folders + # but don't add directories that are already in the path + directories = @modules.map(&:underscore).select do |m| + Deimos.config.schema.generated_class_path.exclude?(m) + end + + file_prefix = "#{directories.join('/')}/#{file_prefix}" end + filename = "#{Deimos.config.schema.generated_class_path}/#{file_prefix}.rb" template(SCHEMA_CLASS_FILE, filename, force: true) end diff --git a/regenerate_test_schema_classes.rb b/regenerate_test_schema_classes.rb index 04ed1f2b..baba3d34 100755 --- a/regenerate_test_schema_classes.rb +++ b/regenerate_test_schema_classes.rb @@ -21,8 +21,11 @@ def consume(payload, metadata); end deimos_config.schema.path = "spec/schemas" deimos_config.schema.backend = :avro_validation deimos_config.schema.generated_class_path = './spec/schemas' - deimos_config.schema.generate_namespace_folders = true - deimos_config.schema.nest_child_schemas = true + deimos_config.schema.use_full_namespace = true + deimos_config.schema.schema_namespace_map = { + 'com' => 'Schemas', + 'com.my-namespace.my-suborg' => %w(Schemas MyNamespace) + } consumer do class_name 'MyConsumer' @@ -56,6 +59,14 @@ def consume(payload, metadata); end key_config field: :test_id end + consumer do + class_name 'MyConsumer' + topic 'MyTopic' + schema 'MyLongNamespaceSchema' + namespace 'com.my-namespace.my-suborg' + key_config field: :test_id + end + producer do class_name 'MyConsumer' topic 'MyTopic' diff --git a/spec/active_record_batch_consumer_spec.rb b/spec/active_record_batch_consumer_spec.rb index 3777e8a4..6c5fb43c 100644 --- a/spec/active_record_batch_consumer_spec.rb +++ b/spec/active_record_batch_consumer_spec.rb @@ -78,7 +78,7 @@ def publish_batch(messages) before(:each) do Deimos.configure do |config| config.schema.use_schema_classes = use_schema_classes - config.schema.generate_namespace_folders = true + config.schema.use_full_namespace = true end end diff --git a/spec/active_record_consumer_spec.rb b/spec/active_record_consumer_spec.rb index fae7807c..7605b833 100644 --- a/spec/active_record_consumer_spec.rb +++ b/spec/active_record_consumer_spec.rb @@ -143,7 +143,7 @@ def as_json(_opts={}) before(:each) do Deimos.configure do |config| config.schema.use_schema_classes = use_schema_classes - config.schema.generate_namespace_folders = true + config.schema.use_full_namespace = true end end diff --git a/spec/active_record_producer_spec.rb b/spec/active_record_producer_spec.rb index ec576630..ae732c72 100644 --- a/spec/active_record_producer_spec.rb +++ b/spec/active_record_producer_spec.rb @@ -71,7 +71,7 @@ def self.post_process(batch) before(:each) do Deimos.configure do |config| config.schema.use_schema_classes = use_schema_classes - config.schema.generate_namespace_folders = true + config.schema.use_full_namespace = true end end diff --git a/spec/batch_consumer_spec.rb b/spec/batch_consumer_spec.rb index 1b4de1a8..b742915a 100644 --- a/spec/batch_consumer_spec.rb +++ b/spec/batch_consumer_spec.rb @@ -42,7 +42,7 @@ def consume_batch(_payloads, _metadata) before(:each) do Deimos.configure do |config| config.schema.use_schema_classes = use_schema_classes - config.schema.generate_namespace_folders = true + config.schema.use_full_namespace = true end end diff --git a/spec/consumer_spec.rb b/spec/consumer_spec.rb index d5cd3962..4db04253 100644 --- a/spec/consumer_spec.rb +++ b/spec/consumer_spec.rb @@ -31,7 +31,7 @@ def consume(_payload, _metadata) before(:each) do Deimos.configure do |config| config.schema.use_schema_classes = use_schema_classes - config.schema.generate_namespace_folders = true + config.schema.use_full_namespace = true end end @@ -138,7 +138,7 @@ def consume(_payload, _metadata) before(:each) do Deimos.configure do |config| config.schema.use_schema_classes = true - config.schema.generate_namespace_folders = true + config.schema.use_full_namespace = true end end diff --git a/spec/generators/schema_class_generator_spec.rb b/spec/generators/schema_class_generator_spec.rb index 00c87437..7293cabb 100644 --- a/spec/generators/schema_class_generator_spec.rb +++ b/spec/generators/schema_class_generator_spec.rb @@ -217,13 +217,30 @@ def dump(value) context 'with namespace folders' do it 'should generate the correct classes' do - Deimos.with_config('schema.generate_namespace_folders' => true) do + Deimos.with_config('schema.use_full_namespace' => true) do described_class.start expect(files).to match_snapshot('namespace_folders', snapshot_serializer: MultiFileSerializer) end end end + context 'with namespace map' do + it 'should generate the correct classes' do + Deimos.with_config( + { + 'schema.use_full_namespace' => true, + 'schema.schema_namespace_map' => { + 'com' => 'Schemas', + 'com.my-namespace.my-suborg' => %w(Schemas MyNamespace) + } + } + ) do + described_class.start + expect(files).to match_snapshot('namespace_map', snapshot_serializer: MultiFileSerializer) + end + end + end + context 'nested true' do it 'should generate the correct classes' do Deimos.with_config('schema.nest_child_schemas' => true) do diff --git a/spec/schemas/com/my-namespace/my-suborg/MyLongNamespaceSchema.avsc b/spec/schemas/com/my-namespace/my-suborg/MyLongNamespaceSchema.avsc new file mode 100644 index 00000000..85abcda3 --- /dev/null +++ b/spec/schemas/com/my-namespace/my-suborg/MyLongNamespaceSchema.avsc @@ -0,0 +1,18 @@ +{ + "namespace": "com.my-namespace.my-suborg", + "name": "MyLongNamespaceSchema", + "type": "record", + "doc": "Test schema", + "fields": [ + { + "name": "test_id", + "type": "string", + "doc": "test string" + }, + { + "name": "some_int", + "type": "int", + "doc": "test int" + } + ] +} diff --git a/spec/schemas/my_namespace/generated.rb b/spec/schemas/my_namespace/generated.rb index e1b40cce..a406e637 100644 --- a/spec/schemas/my_namespace/generated.rb +++ b/spec/schemas/my_namespace/generated.rb @@ -128,7 +128,7 @@ def namespace end def self.tombstone(key) - record = self.new + record = self.allocate record.tombstone_key = key record.a_string = key record diff --git a/spec/schemas/my_namespace/my_long_namespace_schema.rb b/spec/schemas/my_namespace/my_long_namespace_schema.rb new file mode 100644 index 00000000..bb927820 --- /dev/null +++ b/spec/schemas/my_namespace/my_long_namespace_schema.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + def self.tombstone(key) + record = self.allocate + record.tombstone_key = key + record.test_id = key + record + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end; end diff --git a/spec/schemas/my_namespace/my_nested_schema.rb b/spec/schemas/my_namespace/my_nested_schema.rb index 9ce98440..bcfc7c3f 100644 --- a/spec/schemas/my_namespace/my_nested_schema.rb +++ b/spec/schemas/my_namespace/my_nested_schema.rb @@ -104,7 +104,7 @@ def namespace end def self.tombstone(key) - record = self.new + record = self.allocate record.tombstone_key = key record.test_id = key record diff --git a/spec/schemas/my_namespace/my_schema.rb b/spec/schemas/my_namespace/my_schema.rb index 07ad04e1..ff14ea49 100644 --- a/spec/schemas/my_namespace/my_schema.rb +++ b/spec/schemas/my_namespace/my_schema.rb @@ -43,7 +43,7 @@ def namespace end def self.tombstone(key) - record = self.new + record = self.allocate record.tombstone_key = MySchemaKey.initialize_from_value(key) record.payload_key = key record diff --git a/spec/schemas/my_namespace/my_schema_with_circular_reference.rb b/spec/schemas/my_namespace/my_schema_with_circular_reference.rb index a34ba639..d9f4238e 100644 --- a/spec/schemas/my_namespace/my_schema_with_circular_reference.rb +++ b/spec/schemas/my_namespace/my_schema_with_circular_reference.rb @@ -68,7 +68,7 @@ def namespace end def self.tombstone(key) - record = self.new + record = self.allocate record end diff --git a/spec/schemas/my_namespace/my_schema_with_complex_type.rb b/spec/schemas/my_namespace/my_schema_with_complex_type.rb index dd8449fb..9dc187d4 100644 --- a/spec/schemas/my_namespace/my_schema_with_complex_type.rb +++ b/spec/schemas/my_namespace/my_schema_with_complex_type.rb @@ -9,7 +9,7 @@ class MySchemaWithComplexType < Deimos::SchemaClass::Record ### Secondary Schema Classes ### # Autogenerated Schema for Record at com.my-namespace.ARecord class ARecord < Deimos::SchemaClass::Record - + ### Attribute Accessors ### # @return [String] attr_accessor :a_record_field @@ -185,7 +185,7 @@ def namespace end def self.tombstone(key) - record = self.new + record = self.allocate record.tombstone_key = key record.test_id = key record diff --git a/spec/schemas/my_namespace/my_updated_schema.rb b/spec/schemas/my_namespace/my_updated_schema.rb index 2ece1dd9..f242192a 100644 --- a/spec/schemas/my_namespace/my_updated_schema.rb +++ b/spec/schemas/my_namespace/my_updated_schema.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.MySchema class MyUpdatedSchema < Schemas::MyNamespace::MySchema @@ -16,3 +16,4 @@ def initialize(test_id: nil, end end end +end diff --git a/spec/schemas/request/create_topic.rb b/spec/schemas/my_namespace/request/create_topic.rb similarity index 91% rename from spec/schemas/request/create_topic.rb rename to spec/schemas/my_namespace/request/create_topic.rb index a2519101..ce349406 100644 --- a/spec/schemas/request/create_topic.rb +++ b/spec/schemas/my_namespace/request/create_topic.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module Request +module Schemas; module MyNamespace; module Request ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.request.CreateTopic class CreateTopic < Deimos::SchemaClass::Record @@ -33,4 +33,4 @@ def as_json(_opts={}) } end end -end; end +end; end; end diff --git a/spec/schemas/request/index.rb b/spec/schemas/my_namespace/request/index.rb similarity index 91% rename from spec/schemas/request/index.rb rename to spec/schemas/my_namespace/request/index.rb index cce66273..4e1f36f5 100644 --- a/spec/schemas/request/index.rb +++ b/spec/schemas/my_namespace/request/index.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module Request +module Schemas; module MyNamespace; module Request ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.request.Index class Index < Deimos::SchemaClass::Record @@ -33,4 +33,4 @@ def as_json(_opts={}) } end end -end; end +end; end; end diff --git a/spec/schemas/request/update_request.rb b/spec/schemas/my_namespace/request/update_request.rb similarity index 91% rename from spec/schemas/request/update_request.rb rename to spec/schemas/my_namespace/request/update_request.rb index a25c6a2c..adf9f0cd 100644 --- a/spec/schemas/request/update_request.rb +++ b/spec/schemas/my_namespace/request/update_request.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module Request +module Schemas; module MyNamespace; module Request ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.request.UpdateRequest class UpdateRequest < Deimos::SchemaClass::Record @@ -33,4 +33,4 @@ def as_json(_opts={}) } end end -end; end +end; end; end diff --git a/spec/schemas/response/create_topic.rb b/spec/schemas/my_namespace/response/create_topic.rb similarity index 91% rename from spec/schemas/response/create_topic.rb rename to spec/schemas/my_namespace/response/create_topic.rb index 62da3cf1..b85ae471 100644 --- a/spec/schemas/response/create_topic.rb +++ b/spec/schemas/my_namespace/response/create_topic.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module Response +module Schemas; module MyNamespace; module Response ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.response.CreateTopic class CreateTopic < Deimos::SchemaClass::Record @@ -33,4 +33,4 @@ def as_json(_opts={}) } end end -end; end +end; end; end diff --git a/spec/schemas/response/index.rb b/spec/schemas/my_namespace/response/index.rb similarity index 91% rename from spec/schemas/response/index.rb rename to spec/schemas/my_namespace/response/index.rb index db750736..75016906 100644 --- a/spec/schemas/response/index.rb +++ b/spec/schemas/my_namespace/response/index.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module Response +module Schemas; module MyNamespace; module Response ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.response.Index class Index < Deimos::SchemaClass::Record @@ -33,4 +33,4 @@ def as_json(_opts={}) } end end -end; end +end; end; end diff --git a/spec/schemas/response/update_response.rb b/spec/schemas/my_namespace/response/update_response.rb similarity index 91% rename from spec/schemas/response/update_response.rb rename to spec/schemas/my_namespace/response/update_response.rb index 1678c85a..c4180dae 100644 --- a/spec/schemas/response/update_response.rb +++ b/spec/schemas/my_namespace/response/update_response.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module Response +module Schemas; module MyNamespace; module Response ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.response.UpdateResponse class UpdateResponse < Deimos::SchemaClass::Record @@ -33,4 +33,4 @@ def as_json(_opts={}) } end end -end; end +end; end; end diff --git a/spec/snapshots/consumers-no-nest.snap b/spec/snapshots/consumers-no-nest.snap index 26b5e169..e7c75ca9 100644 --- a/spec/snapshots/consumers-no-nest.snap +++ b/spec/snapshots/consumers-no-nest.snap @@ -267,6 +267,50 @@ module Schemas end +spec/app/lib/schema_classes/my_long_namespace_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end + + spec/app/lib/schema_classes/my_nested_record.rb: # frozen_string_literal: true diff --git a/spec/snapshots/consumers.snap b/spec/snapshots/consumers.snap index cc9a728e..ecd85dc9 100644 --- a/spec/snapshots/consumers.snap +++ b/spec/snapshots/consumers.snap @@ -234,6 +234,50 @@ module Schemas end +spec/app/lib/schema_classes/my_long_namespace_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end + + spec/app/lib/schema_classes/my_nested_schema.rb: # frozen_string_literal: true diff --git a/spec/snapshots/consumers_and_producers-no-nest.snap b/spec/snapshots/consumers_and_producers-no-nest.snap index c00fdace..cec26bc1 100644 --- a/spec/snapshots/consumers_and_producers-no-nest.snap +++ b/spec/snapshots/consumers_and_producers-no-nest.snap @@ -267,6 +267,50 @@ module Schemas end +spec/app/lib/schema_classes/my_long_namespace_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end + + spec/app/lib/schema_classes/my_nested_record.rb: # frozen_string_literal: true diff --git a/spec/snapshots/consumers_and_producers.snap b/spec/snapshots/consumers_and_producers.snap index 5f83ad0c..12985cd7 100644 --- a/spec/snapshots/consumers_and_producers.snap +++ b/spec/snapshots/consumers_and_producers.snap @@ -234,6 +234,50 @@ module Schemas end +spec/app/lib/schema_classes/my_long_namespace_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end + + spec/app/lib/schema_classes/my_nested_schema.rb: # frozen_string_literal: true diff --git a/spec/snapshots/consumers_circular-no-nest.snap b/spec/snapshots/consumers_circular-no-nest.snap index 6666a33a..1c35c61b 100644 --- a/spec/snapshots/consumers_circular-no-nest.snap +++ b/spec/snapshots/consumers_circular-no-nest.snap @@ -260,6 +260,50 @@ module Schemas end +spec/app/lib/schema_classes/my_long_namespace_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end + + spec/app/lib/schema_classes/my_nested_record.rb: # frozen_string_literal: true diff --git a/spec/snapshots/consumers_circular.snap b/spec/snapshots/consumers_circular.snap index 9784e4d8..fae0ae7f 100644 --- a/spec/snapshots/consumers_circular.snap +++ b/spec/snapshots/consumers_circular.snap @@ -227,6 +227,50 @@ module Schemas end +spec/app/lib/schema_classes/my_long_namespace_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end + + spec/app/lib/schema_classes/my_nested_schema.rb: # frozen_string_literal: true diff --git a/spec/snapshots/consumers_complex_types-no-nest.snap b/spec/snapshots/consumers_complex_types-no-nest.snap index 04153d2e..a5800f77 100644 --- a/spec/snapshots/consumers_complex_types-no-nest.snap +++ b/spec/snapshots/consumers_complex_types-no-nest.snap @@ -260,6 +260,50 @@ module Schemas end +spec/app/lib/schema_classes/my_long_namespace_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end + + spec/app/lib/schema_classes/my_nested_record.rb: # frozen_string_literal: true diff --git a/spec/snapshots/consumers_complex_types.snap b/spec/snapshots/consumers_complex_types.snap index 60d4eeff..34dacd8c 100644 --- a/spec/snapshots/consumers_complex_types.snap +++ b/spec/snapshots/consumers_complex_types.snap @@ -227,6 +227,50 @@ module Schemas end +spec/app/lib/schema_classes/my_long_namespace_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end + + spec/app/lib/schema_classes/my_nested_schema.rb: # frozen_string_literal: true diff --git a/spec/snapshots/consumers_nested-no-nest.snap b/spec/snapshots/consumers_nested-no-nest.snap index 756f13ea..c3cf93bc 100644 --- a/spec/snapshots/consumers_nested-no-nest.snap +++ b/spec/snapshots/consumers_nested-no-nest.snap @@ -260,6 +260,50 @@ module Schemas end +spec/app/lib/schema_classes/my_long_namespace_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end + + spec/app/lib/schema_classes/my_nested_record.rb: # frozen_string_literal: true diff --git a/spec/snapshots/consumers_nested.snap b/spec/snapshots/consumers_nested.snap index 47e2e0e2..3d778f33 100644 --- a/spec/snapshots/consumers_nested.snap +++ b/spec/snapshots/consumers_nested.snap @@ -227,6 +227,50 @@ module Schemas end +spec/app/lib/schema_classes/my_long_namespace_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end + + spec/app/lib/schema_classes/my_nested_schema.rb: # frozen_string_literal: true diff --git a/spec/snapshots/namespace_folders.snap b/spec/snapshots/namespace_folders.snap index 5369fc8b..c547bea3 100644 --- a/spec/snapshots/namespace_folders.snap +++ b/spec/snapshots/namespace_folders.snap @@ -1,8 +1,8 @@ -spec/app/lib/schema_classes/my_namespace/generated.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/generated.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.Generated class Generated < Deimos::SchemaClass::Record @@ -153,14 +153,14 @@ module Schemas; module MyNamespace } end end -end; end +end; end; end -spec/app/lib/schema_classes/my_namespace/my_nested_schema.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/my_nested_schema.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.MyNestedSchema class MyNestedSchema < Deimos::SchemaClass::Record @@ -280,14 +280,14 @@ module Schemas; module MyNamespace } end end -end; end +end; end; end -spec/app/lib/schema_classes/my_namespace/my_schema.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/my_schema.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.MySchema class MySchema < Deimos::SchemaClass::Record @@ -344,14 +344,14 @@ module Schemas; module MyNamespace } end end -end; end +end; end; end -spec/app/lib/schema_classes/my_namespace/my_schema_compound_key.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/my_schema_compound_key.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.MySchemaCompound_key class MySchemaCompoundKey < Deimos::SchemaClass::Record @@ -388,14 +388,14 @@ module Schemas; module MyNamespace } end end -end; end +end; end; end -spec/app/lib/schema_classes/my_namespace/my_schema_id_key.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/my_schema_id_key.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.MySchemaId_key class MySchemaIdKey < Deimos::SchemaClass::Record @@ -427,14 +427,14 @@ module Schemas; module MyNamespace } end end -end; end +end; end; end -spec/app/lib/schema_classes/my_namespace/my_schema_key.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/my_schema_key.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.MySchema_key class MySchemaKey < Deimos::SchemaClass::Record @@ -466,14 +466,14 @@ module Schemas; module MyNamespace } end end -end; end +end; end; end -spec/app/lib/schema_classes/my_namespace/my_schema_with_boolean.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/my_schema_with_boolean.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.MySchemaWithBooleans class MySchemaWithBoolean < Deimos::SchemaClass::Record @@ -510,14 +510,14 @@ module Schemas; module MyNamespace } end end -end; end +end; end; end -spec/app/lib/schema_classes/my_namespace/my_schema_with_circular_reference.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/my_schema_with_circular_reference.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.MySchemaWithCircularReference class MySchemaWithCircularReference < Deimos::SchemaClass::Record @@ -590,14 +590,14 @@ module Schemas; module MyNamespace } end end -end; end +end; end; end -spec/app/lib/schema_classes/my_namespace/my_schema_with_complex_type.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/my_schema_with_complex_type.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.MySchemaWithComplexTypes class MySchemaWithComplexType < Deimos::SchemaClass::Record @@ -799,14 +799,14 @@ module Schemas; module MyNamespace } end end -end; end +end; end; end -spec/app/lib/schema_classes/my_namespace/my_schema_with_date_time.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/my_schema_with_date_time.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.MySchemaWithDateTimes class MySchemaWithDateTime < Deimos::SchemaClass::Record @@ -858,14 +858,14 @@ module Schemas; module MyNamespace } end end -end; end +end; end; end -spec/app/lib/schema_classes/my_namespace/my_schema_with_id.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/my_schema_with_id.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.MySchemaWithId class MySchemaWithId < Deimos::SchemaClass::Record @@ -912,14 +912,14 @@ module Schemas; module MyNamespace } end end -end; end +end; end; end -spec/app/lib/schema_classes/my_namespace/my_schema_with_unique_id.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/my_schema_with_unique_id.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### # Autogenerated Schema for Record at com.my-namespace.MySchemaWithUniqueId class MySchemaWithUniqueId < Deimos::SchemaClass::Record @@ -971,223 +971,187 @@ module Schemas; module MyNamespace } end end -end; end +end; end; end -spec/app/lib/schema_classes/my_namespace/wibble.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/my_suborg/my_long_namespace_schema.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace; module MySuborg ### Primary Schema Class ### - # Autogenerated Schema for Record at com.my-namespace.Wibble - class Wibble < Deimos::SchemaClass::Record + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record ### Attribute Accessors ### - # @return [Integer] - attr_accessor :id - # @return [Integer] - attr_accessor :wibble_id # @return [String] - attr_accessor :name - # @return [String] - attr_accessor :floop - # @return [Integer] - attr_accessor :birthday_int - # @return [Integer] - attr_accessor :birthday_long - # @return [nil, Integer] - attr_accessor :birthday_optional - # @return [Integer] - attr_accessor :updated_at + attr_accessor :test_id # @return [Integer] - attr_accessor :created_at + attr_accessor :some_int # @override - def initialize(id: nil, - wibble_id: nil, - name: nil, - floop: nil, - birthday_int: nil, - birthday_long: nil, - birthday_optional: nil, - updated_at: nil, - created_at: nil) + def initialize(test_id: nil, + some_int: nil) super - self.id = id - self.wibble_id = wibble_id - self.name = name - self.floop = floop - self.birthday_int = birthday_int - self.birthday_long = birthday_long - self.birthday_optional = birthday_optional - self.updated_at = updated_at - self.created_at = created_at + self.test_id = test_id + self.some_int = some_int end # @override def schema - 'Wibble' + 'MyLongNamespaceSchema' end # @override def namespace - 'com.my-namespace' + 'com.my-namespace.my-suborg' end # @override def as_json(_opts={}) { - 'id' => @id, - 'wibble_id' => @wibble_id, - 'name' => @name, - 'floop' => @floop, - 'birthday_int' => @birthday_int, - 'birthday_long' => @birthday_long, - 'birthday_optional' => @birthday_optional, - 'updated_at' => @updated_at, - 'created_at' => @created_at + 'test_id' => @test_id, + 'some_int' => @some_int } end end -end; end +end; end; end; end -spec/app/lib/schema_classes/my_namespace/widget.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/request/create_topic.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace; module Request ### Primary Schema Class ### - # Autogenerated Schema for Record at com.my-namespace.Widget - class Widget < Deimos::SchemaClass::Record + # Autogenerated Schema for Record at com.my-namespace.request.CreateTopic + class CreateTopic < Deimos::SchemaClass::Record ### Attribute Accessors ### - # @return [Integer] - attr_accessor :id - # @return [Integer] - attr_accessor :widget_id # @return [String] - attr_accessor :name - # @return [Integer] - attr_accessor :updated_at - # @return [Integer] - attr_accessor :created_at + attr_accessor :request_id # @override - def initialize(id: nil, - widget_id: nil, - name: nil, - updated_at: nil, - created_at: nil) + def initialize(request_id: nil) super - self.id = id - self.widget_id = widget_id - self.name = name - self.updated_at = updated_at - self.created_at = created_at + self.request_id = request_id end # @override def schema - 'Widget' + 'CreateTopic' end # @override def namespace - 'com.my-namespace' + 'com.my-namespace.request' end # @override def as_json(_opts={}) { - 'id' => @id, - 'widget_id' => @widget_id, - 'name' => @name, - 'updated_at' => @updated_at, - 'created_at' => @created_at + 'request_id' => @request_id } end end -end; end +end; end; end; end -spec/app/lib/schema_classes/my_namespace/widget_the_second.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/request/index.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module MyNamespace +module Schemas; module Com; module MyNamespace; module Request ### Primary Schema Class ### - # Autogenerated Schema for Record at com.my-namespace.WidgetTheSecond - class WidgetTheSecond < Deimos::SchemaClass::Record + # Autogenerated Schema for Record at com.my-namespace.request.Index + class Index < Deimos::SchemaClass::Record ### Attribute Accessors ### - # @return [Integer] - attr_accessor :id - # @return [Integer] - attr_accessor :widget_id # @return [String] - attr_accessor :model_id - # @return [Integer] - attr_accessor :updated_at - # @return [Integer] - attr_accessor :created_at + attr_accessor :request_id # @override - def initialize(id: nil, - widget_id: nil, - model_id: nil, - updated_at: nil, - created_at: nil) + def initialize(request_id: nil) super - self.id = id - self.widget_id = widget_id - self.model_id = model_id - self.updated_at = updated_at - self.created_at = created_at + self.request_id = request_id end # @override def schema - 'WidgetTheSecond' + 'Index' end # @override def namespace - 'com.my-namespace' + 'com.my-namespace.request' end # @override def as_json(_opts={}) { - 'id' => @id, - 'widget_id' => @widget_id, - 'model_id' => @model_id, - 'updated_at' => @updated_at, - 'created_at' => @created_at + 'request_id' => @request_id } end end -end; end +end; end; end; end -spec/app/lib/schema_classes/request/create_topic.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/request/update_request.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module Request +module Schemas; module Com; module MyNamespace; module Request ### Primary Schema Class ### - # Autogenerated Schema for Record at com.my-namespace.request.CreateTopic + # Autogenerated Schema for Record at com.my-namespace.request.UpdateRequest + class UpdateRequest < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :update_request_id + + # @override + def initialize(update_request_id: nil) + super + self.update_request_id = update_request_id + end + + # @override + def schema + 'UpdateRequest' + end + + # @override + def namespace + 'com.my-namespace.request' + end + + # @override + def as_json(_opts={}) + { + 'update_request_id' => @update_request_id + } + end + end +end; end; end; end + + +spec/app/lib/schema_classes/schemas/com/my_namespace/response/create_topic.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module Com; module MyNamespace; module Response + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.response.CreateTopic class CreateTopic < Deimos::SchemaClass::Record ### Attribute Accessors ### # @return [String] - attr_accessor :request_id + attr_accessor :response_id # @override - def initialize(request_id: nil) + def initialize(response_id: nil) super - self.request_id = request_id + self.response_id = response_id end # @override @@ -1197,36 +1161,36 @@ module Schemas; module Request # @override def namespace - 'com.my-namespace.request' + 'com.my-namespace.response' end # @override def as_json(_opts={}) { - 'request_id' => @request_id + 'response_id' => @response_id } end end -end; end +end; end; end; end -spec/app/lib/schema_classes/request/index.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/response/index.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module Request +module Schemas; module Com; module MyNamespace; module Response ### Primary Schema Class ### - # Autogenerated Schema for Record at com.my-namespace.request.Index + # Autogenerated Schema for Record at com.my-namespace.response.Index class Index < Deimos::SchemaClass::Record ### Attribute Accessors ### # @return [String] - attr_accessor :request_id + attr_accessor :response_id # @override - def initialize(request_id: nil) + def initialize(response_id: nil) super - self.request_id = request_id + self.response_id = response_id end # @override @@ -1236,171 +1200,251 @@ module Schemas; module Request # @override def namespace - 'com.my-namespace.request' + 'com.my-namespace.response' end # @override def as_json(_opts={}) { - 'request_id' => @request_id + 'response_id' => @response_id } end end -end; end +end; end; end; end -spec/app/lib/schema_classes/request/update_request.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/response/update_response.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module Request +module Schemas; module Com; module MyNamespace; module Response ### Primary Schema Class ### - # Autogenerated Schema for Record at com.my-namespace.request.UpdateRequest - class UpdateRequest < Deimos::SchemaClass::Record + # Autogenerated Schema for Record at com.my-namespace.response.UpdateResponse + class UpdateResponse < Deimos::SchemaClass::Record ### Attribute Accessors ### # @return [String] - attr_accessor :update_request_id + attr_accessor :update_response_id # @override - def initialize(update_request_id: nil) + def initialize(update_response_id: nil) super - self.update_request_id = update_request_id + self.update_response_id = update_response_id end # @override def schema - 'UpdateRequest' + 'UpdateResponse' end # @override def namespace - 'com.my-namespace.request' + 'com.my-namespace.response' end # @override def as_json(_opts={}) { - 'update_request_id' => @update_request_id + 'update_response_id' => @update_response_id } end end -end; end +end; end; end; end -spec/app/lib/schema_classes/response/create_topic.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/wibble.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module Response +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### - # Autogenerated Schema for Record at com.my-namespace.response.CreateTopic - class CreateTopic < Deimos::SchemaClass::Record + # Autogenerated Schema for Record at com.my-namespace.Wibble + class Wibble < Deimos::SchemaClass::Record ### Attribute Accessors ### + # @return [Integer] + attr_accessor :id + # @return [Integer] + attr_accessor :wibble_id # @return [String] - attr_accessor :response_id + attr_accessor :name + # @return [String] + attr_accessor :floop + # @return [Integer] + attr_accessor :birthday_int + # @return [Integer] + attr_accessor :birthday_long + # @return [nil, Integer] + attr_accessor :birthday_optional + # @return [Integer] + attr_accessor :updated_at + # @return [Integer] + attr_accessor :created_at # @override - def initialize(response_id: nil) + def initialize(id: nil, + wibble_id: nil, + name: nil, + floop: nil, + birthday_int: nil, + birthday_long: nil, + birthday_optional: nil, + updated_at: nil, + created_at: nil) super - self.response_id = response_id + self.id = id + self.wibble_id = wibble_id + self.name = name + self.floop = floop + self.birthday_int = birthday_int + self.birthday_long = birthday_long + self.birthday_optional = birthday_optional + self.updated_at = updated_at + self.created_at = created_at end # @override def schema - 'CreateTopic' + 'Wibble' end # @override def namespace - 'com.my-namespace.response' + 'com.my-namespace' end # @override def as_json(_opts={}) { - 'response_id' => @response_id + 'id' => @id, + 'wibble_id' => @wibble_id, + 'name' => @name, + 'floop' => @floop, + 'birthday_int' => @birthday_int, + 'birthday_long' => @birthday_long, + 'birthday_optional' => @birthday_optional, + 'updated_at' => @updated_at, + 'created_at' => @created_at } end end -end; end +end; end; end -spec/app/lib/schema_classes/response/index.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/widget.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module Response +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### - # Autogenerated Schema for Record at com.my-namespace.response.Index - class Index < Deimos::SchemaClass::Record + # Autogenerated Schema for Record at com.my-namespace.Widget + class Widget < Deimos::SchemaClass::Record ### Attribute Accessors ### + # @return [Integer] + attr_accessor :id + # @return [Integer] + attr_accessor :widget_id # @return [String] - attr_accessor :response_id + attr_accessor :name + # @return [Integer] + attr_accessor :updated_at + # @return [Integer] + attr_accessor :created_at # @override - def initialize(response_id: nil) + def initialize(id: nil, + widget_id: nil, + name: nil, + updated_at: nil, + created_at: nil) super - self.response_id = response_id + self.id = id + self.widget_id = widget_id + self.name = name + self.updated_at = updated_at + self.created_at = created_at end # @override def schema - 'Index' + 'Widget' end # @override def namespace - 'com.my-namespace.response' + 'com.my-namespace' end # @override def as_json(_opts={}) { - 'response_id' => @response_id + 'id' => @id, + 'widget_id' => @widget_id, + 'name' => @name, + 'updated_at' => @updated_at, + 'created_at' => @created_at } end end -end; end +end; end; end -spec/app/lib/schema_classes/response/update_response.rb: +spec/app/lib/schema_classes/schemas/com/my_namespace/widget_the_second.rb: # frozen_string_literal: true # This file is autogenerated by Deimos, Do NOT modify -module Schemas; module Response +module Schemas; module Com; module MyNamespace ### Primary Schema Class ### - # Autogenerated Schema for Record at com.my-namespace.response.UpdateResponse - class UpdateResponse < Deimos::SchemaClass::Record + # Autogenerated Schema for Record at com.my-namespace.WidgetTheSecond + class WidgetTheSecond < Deimos::SchemaClass::Record ### Attribute Accessors ### + # @return [Integer] + attr_accessor :id + # @return [Integer] + attr_accessor :widget_id # @return [String] - attr_accessor :update_response_id + attr_accessor :model_id + # @return [Integer] + attr_accessor :updated_at + # @return [Integer] + attr_accessor :created_at # @override - def initialize(update_response_id: nil) + def initialize(id: nil, + widget_id: nil, + model_id: nil, + updated_at: nil, + created_at: nil) super - self.update_response_id = update_response_id + self.id = id + self.widget_id = widget_id + self.model_id = model_id + self.updated_at = updated_at + self.created_at = created_at end # @override def schema - 'UpdateResponse' + 'WidgetTheSecond' end # @override def namespace - 'com.my-namespace.response' + 'com.my-namespace' end # @override def as_json(_opts={}) { - 'update_response_id' => @update_response_id + 'id' => @id, + 'widget_id' => @widget_id, + 'model_id' => @model_id, + 'updated_at' => @updated_at, + 'created_at' => @created_at } end end -end; end +end; end; end diff --git a/spec/snapshots/namespace_map.snap b/spec/snapshots/namespace_map.snap new file mode 100644 index 00000000..1a1b3a10 --- /dev/null +++ b/spec/snapshots/namespace_map.snap @@ -0,0 +1,1450 @@ +spec/app/lib/schema_classes/schemas/my_namespace/generated.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.Generated + class Generated < Deimos::SchemaClass::Record + + ### Secondary Schema Classes ### + # Autogenerated Schema for Record at com.my-namespace.ARecord + class ARecord < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :a_record_field + + # @override + def initialize(a_record_field: nil) + super + self.a_record_field = a_record_field + end + + # @override + def schema + 'ARecord' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'a_record_field' => @a_record_field + } + end + end + + # Autogenerated Schema for Enum at com.my-namespace.AnEnum + class AnEnum < Deimos::SchemaClass::Enum + # @return ['sym1', 'sym2'] + attr_accessor :an_enum + + # @override + def symbols + %w(sym1 sym2) + end + end + + + ### Attribute Readers ### + # @return [AnEnum] + attr_reader :an_enum + # @return [ARecord] + attr_reader :a_record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :a_string + # @return [Integer] + attr_accessor :a_int + # @return [Integer] + attr_accessor :a_long + # @return [Float] + attr_accessor :a_float + # @return [Float] + attr_accessor :a_double + # @return [nil, Integer] + attr_accessor :an_optional_int + # @return [Array] + attr_accessor :an_array + # @return [Hash] + attr_accessor :a_map + # @return [String] + attr_accessor :timestamp + # @return [String] + attr_accessor :message_id + + ### Attribute Writers ### + # @return [AnEnum] + def an_enum=(value) + @an_enum = AnEnum.initialize_from_value(value) + end + + # @return [ARecord] + def a_record=(value) + @a_record = ARecord.initialize_from_value(value) + end + + # @override + def initialize(a_string: nil, + a_int: nil, + a_long: nil, + a_float: nil, + a_double: nil, + an_optional_int: nil, + an_enum: nil, + an_array: nil, + a_map: nil, + timestamp: nil, + message_id: nil, + a_record: nil) + super + self.a_string = a_string + self.a_int = a_int + self.a_long = a_long + self.a_float = a_float + self.a_double = a_double + self.an_optional_int = an_optional_int + self.an_enum = an_enum + self.an_array = an_array + self.a_map = a_map + self.timestamp = timestamp + self.message_id = message_id + self.a_record = a_record + end + + # @override + def schema + 'Generated' + end + + # @override + def namespace + 'com.my-namespace' + end + + def self.tombstone(key) + record = self.allocate + record.tombstone_key = key + record.a_string = key + record + end + + # @override + def as_json(_opts={}) + { + 'a_string' => @a_string, + 'a_int' => @a_int, + 'a_long' => @a_long, + 'a_float' => @a_float, + 'a_double' => @a_double, + 'an_optional_int' => @an_optional_int, + 'an_enum' => @an_enum&.as_json, + 'an_array' => @an_array, + 'a_map' => @a_map, + 'timestamp' => @timestamp, + 'message_id' => @message_id, + 'a_record' => @a_record&.as_json + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/my_long_namespace_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/my_nested_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.MyNestedSchema + class MyNestedSchema < Deimos::SchemaClass::Record + + ### Secondary Schema Classes ### + # Autogenerated Schema for Record at com.my-namespace.MyNestedRecord + class MyNestedRecord < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [Integer] + attr_accessor :some_int + # @return [Float] + attr_accessor :some_float + # @return [String] + attr_accessor :some_string + # @return [nil, Integer] + attr_accessor :some_optional_int + + # @override + def initialize(some_int: nil, + some_float: nil, + some_string: nil, + some_optional_int: nil) + super + self.some_int = some_int + self.some_float = some_float + self.some_string = some_string + self.some_optional_int = some_optional_int + end + + # @override + def schema + 'MyNestedRecord' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'some_int' => @some_int, + 'some_float' => @some_float, + 'some_string' => @some_string, + 'some_optional_int' => @some_optional_int + } + end + end + + + ### Attribute Readers ### + # @return [MyNestedRecord] + attr_reader :some_nested_record + # @return [nil, MyNestedRecord] + attr_reader :some_optional_record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Float] + attr_accessor :test_float + # @return [Array] + attr_accessor :test_array + + ### Attribute Writers ### + # @return [MyNestedRecord] + def some_nested_record=(value) + @some_nested_record = MyNestedRecord.initialize_from_value(value) + end + + # @return [nil, MyNestedRecord] + def some_optional_record=(value) + @some_optional_record = MyNestedRecord.initialize_from_value(value) + end + + # @override + def initialize(test_id: nil, + test_float: nil, + test_array: nil, + some_nested_record: nil, + some_optional_record: nil) + super + self.test_id = test_id + self.test_float = test_float + self.test_array = test_array + self.some_nested_record = some_nested_record + self.some_optional_record = some_optional_record + end + + # @override + def schema + 'MyNestedSchema' + end + + # @override + def namespace + 'com.my-namespace' + end + + def self.tombstone(key) + record = self.allocate + record.tombstone_key = key + record.test_id = key + record + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'test_float' => @test_float, + 'test_array' => @test_array, + 'some_nested_record' => @some_nested_record&.as_json, + 'some_optional_record' => @some_optional_record&.as_json + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/my_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.MySchema + class MySchema < Deimos::SchemaClass::Record + + ### Attribute Readers ### + # @return [MySchemaKey] + attr_reader :payload_key + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + ### Attribute Writers ### + # @return [MySchemaKey] + def payload_key=(value) + @payload_key = MySchemaKey.initialize_from_value(value) + end + + # @override + def initialize(test_id: nil, + some_int: nil, + payload_key: nil) + super + self.test_id = test_id + self.some_int = some_int + self.payload_key = payload_key + end + + # @override + def schema + 'MySchema' + end + + # @override + def namespace + 'com.my-namespace' + end + + def self.tombstone(key) + record = self.allocate + record.tombstone_key = MySchemaKey.initialize_from_value(key) + record.payload_key = key + record + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int, + 'payload_key' => @payload_key&.as_json + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/my_schema_compound_key.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.MySchemaCompound_key + class MySchemaCompoundKey < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :part_one + # @return [String] + attr_accessor :part_two + + # @override + def initialize(part_one: nil, + part_two: nil) + super + self.part_one = part_one + self.part_two = part_two + end + + # @override + def schema + 'MySchemaCompound_key' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'part_one' => @part_one, + 'part_two' => @part_two + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/my_schema_id_key.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.MySchemaId_key + class MySchemaIdKey < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [Integer] + attr_accessor :id + + # @override + def initialize(id: nil) + super + self.id = id + end + + # @override + def schema + 'MySchemaId_key' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'id' => @id + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/my_schema_key.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.MySchema_key + class MySchemaKey < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + + # @override + def initialize(test_id: nil) + super + self.test_id = test_id + end + + # @override + def schema + 'MySchema_key' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/my_schema_with_boolean.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.MySchemaWithBooleans + class MySchemaWithBoolean < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Boolean] + attr_accessor :some_bool + + # @override + def initialize(test_id: nil, + some_bool: nil) + super + self.test_id = test_id + self.some_bool = some_bool + end + + # @override + def schema + 'MySchemaWithBooleans' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_bool' => @some_bool + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/my_schema_with_circular_reference.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.MySchemaWithCircularReference + class MySchemaWithCircularReference < Deimos::SchemaClass::Record + + ### Secondary Schema Classes ### + # Autogenerated Schema for Record at com.my-namespace.Property + class Property < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [Boolean, Integer, Integer, Float, Float, String, Array, Hash] + attr_accessor :property + + # @override + def initialize(property: nil) + super + self.property = property + end + + # @override + def schema + 'Property' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'property' => @property + } + end + end + + + ### Attribute Readers ### + # @return [Hash] + attr_reader :properties + + ### Attribute Writers ### + # @return [Hash] + def properties=(values) + @properties = values&.transform_values do |value| + Property.initialize_from_value(value) + end + end + + # @override + def initialize(properties: {}) + super + self.properties = properties + end + + # @override + def schema + 'MySchemaWithCircularReference' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'properties' => @properties.transform_values { |v| v&.as_json } + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/my_schema_with_complex_type.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.MySchemaWithComplexTypes + class MySchemaWithComplexType < Deimos::SchemaClass::Record + + ### Secondary Schema Classes ### + # Autogenerated Schema for Record at com.my-namespace.ARecord + class ARecord < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :a_record_field + + # @override + def initialize(a_record_field: nil) + super + self.a_record_field = a_record_field + end + + # @override + def schema + 'ARecord' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'a_record_field' => @a_record_field + } + end + end + + # Autogenerated Schema for Enum at com.my-namespace.AnEnum + class AnEnum < Deimos::SchemaClass::Enum + # @return ['sym1', 'sym2'] + attr_accessor :an_enum + + # @override + def symbols + %w(sym1 sym2) + end + end + + # Autogenerated Schema for Enum at com.my-namespace.AnotherEnum + class AnotherEnum < Deimos::SchemaClass::Enum + # @return ['sym3', 'sym4'] + attr_accessor :another_enum + + # @override + def symbols + %w(sym3 sym4) + end + end + + # Autogenerated Schema for Enum at com.my-namespace.YetAnotherEnum + class YetAnotherEnum < Deimos::SchemaClass::Enum + # @return ['sym5', 'sym6'] + attr_accessor :yet_another_enum + + # @override + def symbols + %w(sym5 sym6) + end + end + + + ### Attribute Readers ### + # @return [ARecord] + attr_reader :some_record + # @return [nil, ARecord] + attr_reader :some_optional_record + # @return [Array] + attr_reader :some_record_array + # @return [Hash] + attr_reader :some_record_map + # @return [Array] + attr_reader :some_enum_array + # @return [nil, AnotherEnum] + attr_reader :some_optional_enum + # @return [YetAnotherEnum] + attr_reader :some_enum_with_default + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Float] + attr_accessor :test_float + # @return [Array] + attr_accessor :test_string_array + # @return [Array] + attr_accessor :test_int_array + # @return [Integer, nil] + attr_accessor :test_optional_int + # @return [Hash] + attr_accessor :some_integer_map + + ### Attribute Writers ### + # @return [ARecord] + def some_record=(value) + @some_record = ARecord.initialize_from_value(value) + end + + # @return [nil, ARecord] + def some_optional_record=(value) + @some_optional_record = ARecord.initialize_from_value(value) + end + + # @return [Array] + def some_record_array=(values) + @some_record_array = values&.map do |value| + ARecord.initialize_from_value(value) + end + end + + # @return [Hash] + def some_record_map=(values) + @some_record_map = values&.transform_values do |value| + ARecord.initialize_from_value(value) + end + end + + # @return [Array] + def some_enum_array=(values) + @some_enum_array = values&.map do |value| + AnEnum.initialize_from_value(value) + end + end + + # @return [nil, AnotherEnum] + def some_optional_enum=(value) + @some_optional_enum = AnotherEnum.initialize_from_value(value) + end + + # @return [YetAnotherEnum] + def some_enum_with_default=(value) + @some_enum_with_default = YetAnotherEnum.initialize_from_value(value) + end + + # @override + def initialize(test_id: nil, + test_float: nil, + test_string_array: ["test"], + test_int_array: [123], + test_optional_int: 123, + some_integer_map: {"abc"=>123}, + some_record: {"a_record_field"=>"Test String"}, + some_optional_record: nil, + some_record_array: nil, + some_record_map: nil, + some_enum_array: nil, + some_optional_enum: nil, + some_enum_with_default: "sym6") + super + self.test_id = test_id + self.test_float = test_float + self.test_string_array = test_string_array + self.test_int_array = test_int_array + self.test_optional_int = test_optional_int + self.some_integer_map = some_integer_map + self.some_record = some_record + self.some_optional_record = some_optional_record + self.some_record_array = some_record_array + self.some_record_map = some_record_map + self.some_enum_array = some_enum_array + self.some_optional_enum = some_optional_enum + self.some_enum_with_default = some_enum_with_default + end + + # @override + def schema + 'MySchemaWithComplexTypes' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'test_float' => @test_float, + 'test_string_array' => @test_string_array, + 'test_int_array' => @test_int_array, + 'test_optional_int' => @test_optional_int, + 'some_integer_map' => @some_integer_map, + 'some_record' => @some_record&.as_json, + 'some_optional_record' => @some_optional_record&.as_json, + 'some_record_array' => @some_record_array.map { |v| v&.as_json }, + 'some_record_map' => @some_record_map.transform_values { |v| v&.as_json }, + 'some_enum_array' => @some_enum_array.map { |v| v&.as_json }, + 'some_optional_enum' => @some_optional_enum&.as_json, + 'some_enum_with_default' => @some_enum_with_default&.as_json + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/my_schema_with_date_time.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.MySchemaWithDateTimes + class MySchemaWithDateTime < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer, nil] + attr_accessor :updated_at + # @return [nil, Integer] + attr_accessor :some_int + # @return [nil, Integer] + attr_accessor :some_datetime_int + # @return [String] + attr_accessor :timestamp + + # @override + def initialize(test_id: nil, + updated_at: nil, + some_int: nil, + some_datetime_int: nil, + timestamp: nil) + super + self.test_id = test_id + self.updated_at = updated_at + self.some_int = some_int + self.some_datetime_int = some_datetime_int + self.timestamp = timestamp + end + + # @override + def schema + 'MySchemaWithDateTimes' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'updated_at' => @updated_at, + 'some_int' => @some_int, + 'some_datetime_int' => @some_datetime_int, + 'timestamp' => @timestamp + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/my_schema_with_id.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.MySchemaWithId + class MySchemaWithId < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + # @return [String] + attr_accessor :message_id + # @return [String] + attr_accessor :timestamp + + # @override + def initialize(test_id: nil, + some_int: nil, + message_id: nil, + timestamp: nil) + super + self.test_id = test_id + self.some_int = some_int + self.message_id = message_id + self.timestamp = timestamp + end + + # @override + def schema + 'MySchemaWithId' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int, + 'message_id' => @message_id, + 'timestamp' => @timestamp + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/my_schema_with_unique_id.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.MySchemaWithUniqueId + class MySchemaWithUniqueId < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [Integer] + attr_accessor :id + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + # @return [String] + attr_accessor :message_id + # @return [String] + attr_accessor :timestamp + + # @override + def initialize(id: nil, + test_id: nil, + some_int: nil, + message_id: nil, + timestamp: nil) + super + self.id = id + self.test_id = test_id + self.some_int = some_int + self.message_id = message_id + self.timestamp = timestamp + end + + # @override + def schema + 'MySchemaWithUniqueId' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'id' => @id, + 'test_id' => @test_id, + 'some_int' => @some_int, + 'message_id' => @message_id, + 'timestamp' => @timestamp + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/request/create_topic.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace; module Request + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.request.CreateTopic + class CreateTopic < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :request_id + + # @override + def initialize(request_id: nil) + super + self.request_id = request_id + end + + # @override + def schema + 'CreateTopic' + end + + # @override + def namespace + 'com.my-namespace.request' + end + + # @override + def as_json(_opts={}) + { + 'request_id' => @request_id + } + end + end +end; end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/request/index.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace; module Request + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.request.Index + class Index < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :request_id + + # @override + def initialize(request_id: nil) + super + self.request_id = request_id + end + + # @override + def schema + 'Index' + end + + # @override + def namespace + 'com.my-namespace.request' + end + + # @override + def as_json(_opts={}) + { + 'request_id' => @request_id + } + end + end +end; end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/request/update_request.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace; module Request + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.request.UpdateRequest + class UpdateRequest < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :update_request_id + + # @override + def initialize(update_request_id: nil) + super + self.update_request_id = update_request_id + end + + # @override + def schema + 'UpdateRequest' + end + + # @override + def namespace + 'com.my-namespace.request' + end + + # @override + def as_json(_opts={}) + { + 'update_request_id' => @update_request_id + } + end + end +end; end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/response/create_topic.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace; module Response + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.response.CreateTopic + class CreateTopic < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :response_id + + # @override + def initialize(response_id: nil) + super + self.response_id = response_id + end + + # @override + def schema + 'CreateTopic' + end + + # @override + def namespace + 'com.my-namespace.response' + end + + # @override + def as_json(_opts={}) + { + 'response_id' => @response_id + } + end + end +end; end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/response/index.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace; module Response + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.response.Index + class Index < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :response_id + + # @override + def initialize(response_id: nil) + super + self.response_id = response_id + end + + # @override + def schema + 'Index' + end + + # @override + def namespace + 'com.my-namespace.response' + end + + # @override + def as_json(_opts={}) + { + 'response_id' => @response_id + } + end + end +end; end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/response/update_response.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace; module Response + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.response.UpdateResponse + class UpdateResponse < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :update_response_id + + # @override + def initialize(update_response_id: nil) + super + self.update_response_id = update_response_id + end + + # @override + def schema + 'UpdateResponse' + end + + # @override + def namespace + 'com.my-namespace.response' + end + + # @override + def as_json(_opts={}) + { + 'update_response_id' => @update_response_id + } + end + end +end; end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/wibble.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.Wibble + class Wibble < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [Integer] + attr_accessor :id + # @return [Integer] + attr_accessor :wibble_id + # @return [String] + attr_accessor :name + # @return [String] + attr_accessor :floop + # @return [Integer] + attr_accessor :birthday_int + # @return [Integer] + attr_accessor :birthday_long + # @return [nil, Integer] + attr_accessor :birthday_optional + # @return [Integer] + attr_accessor :updated_at + # @return [Integer] + attr_accessor :created_at + + # @override + def initialize(id: nil, + wibble_id: nil, + name: nil, + floop: nil, + birthday_int: nil, + birthday_long: nil, + birthday_optional: nil, + updated_at: nil, + created_at: nil) + super + self.id = id + self.wibble_id = wibble_id + self.name = name + self.floop = floop + self.birthday_int = birthday_int + self.birthday_long = birthday_long + self.birthday_optional = birthday_optional + self.updated_at = updated_at + self.created_at = created_at + end + + # @override + def schema + 'Wibble' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'id' => @id, + 'wibble_id' => @wibble_id, + 'name' => @name, + 'floop' => @floop, + 'birthday_int' => @birthday_int, + 'birthday_long' => @birthday_long, + 'birthday_optional' => @birthday_optional, + 'updated_at' => @updated_at, + 'created_at' => @created_at + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/widget.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.Widget + class Widget < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [Integer] + attr_accessor :id + # @return [Integer] + attr_accessor :widget_id + # @return [String] + attr_accessor :name + # @return [Integer] + attr_accessor :updated_at + # @return [Integer] + attr_accessor :created_at + + # @override + def initialize(id: nil, + widget_id: nil, + name: nil, + updated_at: nil, + created_at: nil) + super + self.id = id + self.widget_id = widget_id + self.name = name + self.updated_at = updated_at + self.created_at = created_at + end + + # @override + def schema + 'Widget' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'id' => @id, + 'widget_id' => @widget_id, + 'name' => @name, + 'updated_at' => @updated_at, + 'created_at' => @created_at + } + end + end +end; end + + +spec/app/lib/schema_classes/schemas/my_namespace/widget_the_second.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas; module MyNamespace + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.WidgetTheSecond + class WidgetTheSecond < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [Integer] + attr_accessor :id + # @return [Integer] + attr_accessor :widget_id + # @return [String] + attr_accessor :model_id + # @return [Integer] + attr_accessor :updated_at + # @return [Integer] + attr_accessor :created_at + + # @override + def initialize(id: nil, + widget_id: nil, + model_id: nil, + updated_at: nil, + created_at: nil) + super + self.id = id + self.widget_id = widget_id + self.model_id = model_id + self.updated_at = updated_at + self.created_at = created_at + end + + # @override + def schema + 'WidgetTheSecond' + end + + # @override + def namespace + 'com.my-namespace' + end + + # @override + def as_json(_opts={}) + { + 'id' => @id, + 'widget_id' => @widget_id, + 'model_id' => @model_id, + 'updated_at' => @updated_at, + 'created_at' => @created_at + } + end + end +end; end + diff --git a/spec/snapshots/producers_with_key-no-nest.snap b/spec/snapshots/producers_with_key-no-nest.snap index 9c22ffe2..3a6b5771 100644 --- a/spec/snapshots/producers_with_key-no-nest.snap +++ b/spec/snapshots/producers_with_key-no-nest.snap @@ -260,6 +260,50 @@ module Schemas end +spec/app/lib/schema_classes/my_long_namespace_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end + + spec/app/lib/schema_classes/my_nested_record.rb: # frozen_string_literal: true diff --git a/spec/snapshots/producers_with_key.snap b/spec/snapshots/producers_with_key.snap index dd5c1f22..246eda67 100644 --- a/spec/snapshots/producers_with_key.snap +++ b/spec/snapshots/producers_with_key.snap @@ -227,6 +227,50 @@ module Schemas end +spec/app/lib/schema_classes/my_long_namespace_schema.rb: +# frozen_string_literal: true + +# This file is autogenerated by Deimos, Do NOT modify +module Schemas + ### Primary Schema Class ### + # Autogenerated Schema for Record at com.my-namespace.my-suborg.MyLongNamespaceSchema + class MyLongNamespaceSchema < Deimos::SchemaClass::Record + + ### Attribute Accessors ### + # @return [String] + attr_accessor :test_id + # @return [Integer] + attr_accessor :some_int + + # @override + def initialize(test_id: nil, + some_int: nil) + super + self.test_id = test_id + self.some_int = some_int + end + + # @override + def schema + 'MyLongNamespaceSchema' + end + + # @override + def namespace + 'com.my-namespace.my-suborg' + end + + # @override + def as_json(_opts={}) + { + 'test_id' => @test_id, + 'some_int' => @some_int + } + end + end +end + + spec/app/lib/schema_classes/my_nested_schema.rb: # frozen_string_literal: true