-
-
Notifications
You must be signed in to change notification settings - Fork 208
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: unmatched type for value in oneOf should be ignored #344
fix: unmatched type for value in oneOf should be ignored #344
Conversation
fd949bb
to
1140e92
Compare
test/oneof.test.js
Outdated
@@ -401,3 +401,105 @@ test('oneOf object with field of type string with format or null', (t) => { | |||
prop: toStringify | |||
}), `{"prop":"${toStringify.toISOString()}"}`) | |||
}) | |||
|
|||
test('one array item do not match oneOf types', (t) => { |
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 think this test title should be positive, not negative.
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.
It really should be positive, my 🇺🇸 that tricked me
test/oneof.test.js
Outdated
t.equal('{"data":["foo"]}', responseWithMappedType) | ||
}) | ||
|
||
test('some array items does not match oneOf types', (t) => { |
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 think this test title should be positive, not negative.
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.
It really should be positive, my 🇺🇸 that tricked me
index.js
Outdated
if (i > 0) { | ||
var jsonLastChar = json.slice(-1) | ||
|
||
if (i > 0 && jsonLastChar != '[' && jsonLastChar != ',') { |
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 use !==
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.
My bad, totally missed this, gonna fix it 🙏
index.js
Outdated
for (var i = 0; i < l; i++) { | ||
if (i > 0) { | ||
var jsonLastChar = json.slice(-1) |
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 would do: json[json.length - 1]
.
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.
Sure, gonna change to this
fix: get last json char with json[json.length - 1]
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.
lgtm
Checklist
npm run test
andnpm run benchmark
Related issue: #342