You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
documentation: { hidden: true } on a Hash parameter doesn't hide its nested query parameters #1015
When a hash parameter is hidden from the documentation, its nested children are
still emitted as separate parent[child] query parameters, referencing a
parameter that no longer exists in the document.
Reproduction
require'logger'# only needed in a bare script with activesupport 6.1 on Ruby 3.xrequire'grape'require'grape-swagger'require'rack/test'require'json'classAPI < Grape::APIformat:jsonparamsdooptional:query,type: Stringoptional:filters,type: Hash,documentation: {hidden: true}dooptional:status,type: Stringoptional:kind,type: Stringendendget('/search'){'ok'}add_swagger_documentationendincludeRack::Test::MethodsdefappAPIendget'/swagger_doc'names=JSON.parse(last_response.body).dig('paths','/search','get','parameters').map{_1['name']}putsnames.inspect
Grape::Endpoint#params_object (reopened by grape-swagger, endpoint.rb) checks hidden_parameter? per entry of build_request_params. Nested params arrive as
separate entries (filters[status], …) whose options don't carry the parent's documentation, so the parent's hidden: true is never considered for them
(and the container entry itself is dropped, leaving orphaned children).
Verified on v2.1.1; the same code path is present in v2.2.0 (endpoint.rb and RequestParamParsers::Route). We currently work around it by prepending a
module to Grape::Endpoint that rejects parent[child] entries whose parent is
marked hidden in route.params — happy to PR that as a fix if the approach
fits (note: may overlap with #999).
@seriousdev-gh Thanks for the report, confirmed. Fixed in #1016: children of a hidden parent are now skipped at any depth, and siblings like filters_extra are unaffected. It also makes the parameter-level hidden: proc receive the token_owner, as the route-level one already does. That used to raise ArgumentError.
Activity
numbata commentedon Nov 4, 2026
@seriousdev-gh Thanks for the report, confirmed. Fixed in #1016: children of a hidden parent are now skipped at any depth, and siblings like filters_extra are unaffected. It also makes the parameter-level
hidden: procreceive thetoken_owner, as the route-level one already does. That used to raiseArgumentError.Hide nested params of a hidden Hash parameter (ruby-grape#1016)