Sha256: 1b7548d1af5f138f81e393c4703a2155f19d97252a0469acbe6b830d2d7b6bbc
Contents?: true
Size: 893 Bytes
Versions: 1
Compression:
Stored size: 893 Bytes
Contents
module OpenAPIParser module Schemas class Schema BIG_INT = 2**32 def to_example case type when 'string' then string_example when 'integer' then integer_example when 'number' then Faker::Number.decimal.to_f when 'boolean' then Faker::Boolean.boolean when 'array' then [items.to_example] else # object properties.each_with_object({}) { |(name, schema), obj| obj[name] = schema.to_example } end end private def integer_example if enum enum.to_a.sample else Faker::Number.between(minimum || 1, maximum || BIG_INT) end end def string_example if enum enum.to_a.sample elsif pattern Faker::Base.regexify(pattern) else Faker::Book.title end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fakeit-0.1.1 | lib/fakeit/core_extensions/schema.rb |