Sha256: 701ab04f2f9d0b2aec73d86ddab1b6af0fc17593e81dbb6f4ffa725c63fc0842

Contents?: true

Size: 895 Bytes

Versions: 2

Compression:

Stored size: 895 Bytes

Contents

require 'avro'

module Avro
  class ResolutionCanonicalForm < SchemaNormalization
    def self.to_resolution_form(schema)
      new.to_resolution_form(schema)
    end

    def to_resolution_form(schema)
      MultiJson.dump(normalize_schema(schema))
    end

    private

    # TODO: include aliases once the avro Ruby gem supports them
    # Note: permitted values for defaults are not enforced here.
    # That should be done at the schema level, and is not done currently
    # in the Avro Ruby gem
    def normalize_field(field)
      default_value = if field.default?
                        { default: field.default }
                      else
                        {}
                      end
      super.merge(default_value)
    end

    # TODO: Override normalize_named_type once the Avro Ruby gem supports aliases
    # def normalized_named_type(schema, attributes = {})
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
avro-resolution_canonical_form-0.1.0 lib/avro/resolution_canonical_form.rb
avro-resolution_canonical_form-0.1.0.rc0 lib/avro/resolution_canonical_form.rb