Doc Update Request: Nested re-usable params
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
I'm attempting was attempting to define a re-usable params type and make use of it for a request. The result is I get this: NameError (uninitialized constant Grape::Validations::Types::SymbolCoercer).
Here is my re-usable param structure:
helpers do
params :identifier_type do
optional :id, type: String
optional :name, type: String
exactly_one_of :id, :name
end
end
Since there was no clear examples in the docs of how to go about it, I was trying things like this - which just gave me errors.
params do
required :identifier, type: :identifier_type
end
post '' do
...
end
Eventually, I found a pattern that works:
params do
required :identifier, type: Hash do
use :identifier_type
end
end
post '' do
...
end
Adding something like this to the documentation would be helpful for others, I think
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 with the Grape documentation covering request parameters and reusable params, then check how nested parameter examples are organized. Document the working required :identifier, type: Hash with use :identifier_type pattern and explain that it replaces the failing type: :identifier_type form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100