Sha256: 6665c21acf625f7be86acda5512b1a4799729190d5585c66fab9a3bc36369015

Contents?: true

Size: 903 Bytes

Versions: 3

Compression:

Stored size: 903 Bytes

Contents

require 'avro-patches'

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

3 entries across 3 versions & 1 rubygems

Version Path
avro-resolution_canonical_form-0.2.1 lib/avro/resolution_canonical_form.rb
avro-resolution_canonical_form-0.2.0 lib/avro/resolution_canonical_form.rb
avro-resolution_canonical_form-0.2.0.rc0 lib/avro/resolution_canonical_form.rb