Sha256: f71156acff9820f9876f6069faf5b7a9f2f16c7f2d522a8680b35f27a09ae569
Contents?: true
Size: 733 Bytes
Versions: 9
Compression:
Stored size: 733 Bytes
Contents
module Jimmy class SchemaTypes::Array < SchemaType register! trait :min_items trait :max_items trait(:unique) { attrs[:unique_items] = true } trait Range do |range| min, max = [range.first, range.last].sort min_items min max_items max end trait(Fixnum) { |value| min_items value; max_items value } nested do |schema| (attrs[:items] ||= []) << schema end compile do |hash| hash.merge! camelize_attrs(%i[min_items max_items unique_items]) items = attrs[:items] || [] if items.length > 1 hash['items'] = {'anyOf' => items.map(&:compile)} elsif items.length == 1 hash['items'] = items.first.compile end end end end
Version data entries
9 entries across 9 versions & 1 rubygems