Sha256: ba3f3c64a238254d25ca0ad19c7e18426ed6729dbed47db8ad56e39d799b4208
Contents?: true
Size: 858 Bytes
Versions: 2
Compression:
Stored size: 858 Bytes
Contents
module Fakeit module Openapi module Example MAX_SIZE = 3 def array_example(use_example) size = retries = uniqueItems ? min_array : Faker::Number.between(min_array, max_array) [].tap { |result| generate_items(size, retries, use_example, result) } end private def generate_items(size, retries, use_example, result) loop do item = items.to_example(use_example) if need_retry?(item, result, retries) retries -= 1 elsif (result << item).size >= size break end end end def need_retry?(item, result, retries) uniqueItems && result.include?(item) && retries.positive? end def min_array minItems || 1 end def max_array maxItems || MAX_SIZE end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fakeit-0.1.5 | lib/fakeit/openapi/example/array_example.rb |
fakeit-0.1.4 | lib/fakeit/openapi/example/array_example.rb |