Cannot distinguish empty Array from missing parameters
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
optional :my_field, type: Array
When this optional field is set to [] (a valid value), Grape API removes it from the parameters. I cannot find any way to make this work in 0.14.0. I've tried using the coerce_with specifier, but that does not get called in either case of nil or [].
References:
https://github.com/ruby-grape/grape/issues/1316
https://github.com/ruby-grape/grape/issues/707
I've tried the strategies posted on these other issues, but as mentioned, the coerce_with does not work and there is not anything in the docs about this behavior and how to fix it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied optional Array parameter example in Grape 0.14.0, comparing an explicitly empty array with an omitted parameter. Read the behavior and strategies discussed in issues #1316 and #707; done means the API preserves the distinction between [] and a missing value, with the behavior documented if needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100