-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Nested mount points don't inherit parent declared params #1050
Nested mount points don't inherit parent declared params #1050
Conversation
declared
params
declared
params
If someone is going to fix this, lets carefully document what is being inherited when mounting an endpoint under some scope. |
So, technically this hack makes the fixed spec pass. However, I'm pretty sure it's not the right way to do this. I'm having trouble untangling how settings get passed and inherited and stacked during the API definition process. However, I can explain why both lines are necessary: First, As for the validations line, it's necessary because validations on each endpoint are only set during initialization, which isn't redone when an API is mounted. This might be solvable by having validations be re-pulled from namespace_stackable(:validations) at the time of Anyway, maybe someone with more experience in the internals of Grape can weigh in here. |
@rnubel Thanks! With only a cursory look it's actually possible that this is a viable solution, but I think a useful exercise would be to extend the specs to something that potentially can break. |
Dunno how that path got messed up. Thanks @rnubel for the investigation! |
Okay, I've cleaned up the implementation a bit: master...rnubel:declared_and_nested_mount_missing_params Neither of my suggestions from my original post actually worked out -- However, the new |
Hi guys. Maybe it make sense to merge this pull request? Some of us really need this fix and it will be really cool to see it. |
IIRC, @rnubel's fix did work for my case, but that was almost a year ago and the project that was utilizing this has not been under active development so I can't speak to this. |
I will create new fresh pull request with this fixes because this issue is still available. |
you can close this pull request because all needed changes is already in latest master. |
Closed via #1422 that is. |
Not sure if this is documented elsewhere, but I would expect the following to work:
And for the request
get /something/123/another/456
to return
{ id: 123, my_id: 456 }
, but I only get{ my_id: 456 }
I have attached a failing test case to this PR to demonstrate the issue, though I am unsure as of yet how to go about fixing.