Nested Param Helpers - using *:use* inside a Grape::API::Helper
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 10k
- Forks
- 1.2k
- Avg merge
- 14h 38m
- Merged PRs (30d)
- 92
Description
Hello guys,
I'm trying to reuse param definition in my helpers but the use :param method doesn't seem to work inside Grape::API::Helpers.
The use case is I have two different models that include a third model like this:
module Animal
extend Grape::API::Helpers
params :animal do
requires :mammal, Boolean
requires :other_fields, String
end
end
module Dog
extend Grape::API::Helpers
params :dog do
requires :breed, String
requires :animal do
use :animal
end
end
end
Unfortunately inside Dog grape complains that it cannot find params for :animal. I've tried extending and including the Animal module with no success.
Also the helpers method is not included by Grape::API::Helpers.
Is there any way I can do this?
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 nested parameter example from the issue, focusing on Grape::API::Helpers and the use :animal call inside Dog. Trace how parameter definitions are registered and resolved for helpers, then verify that the nested call finds Animal's definition and that the existing parameter behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100