Skip to content
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

Merged
merged 2 commits into from
Jul 28, 2021

Conversation

joaopedrocampos
Copy link
Contributor

Checklist

Related issue: #342

@joaopedrocampos joaopedrocampos changed the title fix: unmatched type for oneOf should return empty array fix: unmatched type for value in oneOf should be ignored Jul 27, 2021
@joaopedrocampos joaopedrocampos force-pushed the fix-unmatched-schema-oneof branch from fd949bb to 1140e92 Compare July 27, 2021 23:59
@@ -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) => {
Copy link
Member

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.

Copy link
Contributor Author

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

t.equal('{"data":["foo"]}', responseWithMappedType)
})

test('some array items does not match oneOf types', (t) => {
Copy link
Member

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.

Copy link
Contributor Author

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 != ',') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use !==

Copy link
Contributor Author

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)
Copy link
Member

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].

Copy link
Contributor Author

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]
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants