lib/fakeit/openapi/example/string_example.rb in fakeit-0.1.3 vs lib/fakeit/openapi/example/string_example.rb in fakeit-0.1.4

- old
+ new

@@ -2,24 +2,29 @@ module Openapi module Example FORMAT_HANDLERS = { 'uri' => -> { Faker::Internet.url }, 'uuid' => -> { SecureRandom.uuid }, + 'guid' => -> { SecureRandom.uuid }, 'email' => -> { Faker::Internet.email }, 'date' => -> { Faker::Date.backward(100).iso8601 }, 'date-time' => -> { Faker::Time.backward(100).iso8601 } }.freeze def string_example if enum then enum.to_a.sample elsif pattern then Faker::Base.regexify(pattern) elsif format then string_format - elsif minLength || maxLength then string_with_length + elsif length_constraint then string_with_length else Faker::Book.title end end private + + def length_constraint + minLength || maxLength + end def string_with_length Faker::Internet.user_name(min_string_length..max_string_length) end