-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: schema generation can fail #875
Conversation
236b91c
to
df12b84
Compare
df12b84
to
72ba2c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add missing test case while I'm taking time to learn what Record
is
const instance = generate(schema); | ||
expect(instance).toHaveProperty('ip'); | ||
const ip = get(instance, 'ip'); | ||
assertRight(generate(schema), instance => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since generate
returns Either we should have a test of a failure. Maybe a circular object will do the job?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ekhm :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahi, I didn't see this. Will add.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm tentatively accepting since I'm going home, I learned what Record is and it looks way cooler now.
While debugging some JSON Ref issues I noticed that Schema Generation can effectively throw exceptions and would be treated that well.
This PR correctly wraps such situations in
tryCatch
statements.