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

Add nested array coercion spec #2098

Merged
merged 5 commits into from
Aug 27, 2020
Merged

Conversation

braktar
Copy link
Contributor

@braktar braktar commented Aug 25, 2020

The coerce seems to be performed correctly, nevertheless, once we want to match the obtained value to the expected type it fails.

Seems related to : #2054

@braktar braktar changed the title Add nest array coercion spec Add nested array coercion spec Aug 25, 2020
@braktar
Copy link
Contributor Author

braktar commented Aug 25, 2020

My current assumption is that the type_check provided by the infer_type_check method can't evaluate the returned array of array.

coerced?(coerced_val) returns the following error : "*** TypeError Exception: class or module required"

@braktar braktar force-pushed the nested-array-coerce branch from 15019af to 2fa48f1 Compare August 25, 2020 15:17
@braktar braktar force-pushed the nested-array-coerce branch from 1256d3c to 1f0b141 Compare August 26, 2020 11:52
@braktar
Copy link
Contributor Author

braktar commented Aug 26, 2020

Some progress here, recursive objects were not recursively verified. The proposed fix works on our side. But i cannot manage to get it working on spec side...

What I notice is that the rack_params returned by the ParamBuilder is flatten
It gives ['a', 'c', 'b'] instead of [['a','c'],['b']]

[[]] returns [[""]] which seems a bit odd.

[['a', { bar: 0 }], ['b']] is currently considered as incorrect, but not for the good reason. It is currently wrong due to the flatten and not because of the hash

Any hint about it ?

The large model returns as expected {"skills_v1":[["vehicule1"]],"skills_v2":[["vehicule1","vehicule2"]]}
42b5cf5

@dblock
Copy link
Member

dblock commented Aug 26, 2020

Try POSTing JSON in the spec?

@braktar
Copy link
Contributor Author

braktar commented Aug 27, 2020

Thanks !

@dblock dblock merged commit 7e95ac8 into ruby-grape:master Aug 27, 2020
@dblock
Copy link
Member

dblock commented Aug 27, 2020

🚀

@dblock
Copy link
Member

dblock commented Aug 27, 2020

If you feel like doing more work, there's a number of issues that have "coercion" in the title that could be in the same code path ;)

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