Skip to content

Commit

Permalink
Supported guid string format. Close #2
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinFeng committed Jun 25, 2019
1 parent 6f2e730 commit a633055
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/fakeit/openapi/example/string_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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 }
Expand Down
8 changes: 8 additions & 0 deletions spec/fakeit/openapi/example/string_example_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
expect(uuid.to_example).to eq('uuid')
end

it 'guid format example' do
expect(SecureRandom).to receive(:uuid).and_return('guid')

guid = schema.properties['string_guid']

expect(guid.to_example).to eq('guid')
end

it 'email format example' do
expect(Faker::Internet).to receive(:email).and_return('email')

Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/string_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
"type": "string",
"format": "uuid"
},
"string_guid": {
"type": "string",
"format": "guid"
},
"string_email": {
"type": "string",
"format": "email"
Expand Down

0 comments on commit a633055

Please sign in to comment.