support array default value
Open
Nobody has claimed this yet.
bug?
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
I want to declare default value as an array like below.
optional :numbers, type: Array[Integer], default: [1, 2, 5], values: [1, 2, 3, 5, 8]
But, IncompatibleOptionValues exception raised.
.../gems/grape-0.13.0/lib/grape/validations/params_scope.rb:238:in `check_incompatible_option_values': Grape::Exceptions::IncompatibleOptionValues (Grape::Exceptions::IncompatibleOptionValues)
https://github.com/ruby-grape/grape/blob/master/lib/grape/validations/params_scope.rb#L269
This line seems to be modified to support an array default value.
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 in lib/grape/validations/params_scope.rb around check_incompatible_option_values and the referenced line near 269. Trace how Array[Integer] parameters compare their default and values options, then make the example with default [1, 2, 5] valid while preserving incompatible-option checks.
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
- 48/100