@@ -18,7 +18,6 @@ def initialize(route, _params, _settings, _endpoint)
1818 def parse
1919 stackable_values = route . app &.inheritable_setting &.namespace_stackable
2020
21- get_path_params ( stackable_values )
2221 path_params = build_path_params ( stackable_values )
2322
2423 fulfill_params ( path_params )
@@ -54,29 +53,13 @@ def fulfill_params(path_params)
5453 # The route.params hash includes both parametrized params (with a string as a key)
5554 # and well-defined params from body/query (with a symbol as a key).
5655 # We avoid overriding well-defined params with parametrized ones.
57- next if param . is_a? ( String ) && accum . key? ( param . to_sym )
56+ key = param . is_a? ( String ) ? param . to_sym : param
57+ next if param . is_a? ( String ) && accum . key? ( key )
5858
59- value = ( path_params [ param ] || { } ) . merge (
60- definition . is_a? ( Hash ) ? definition : { }
61- )
62-
63- accum [ param . to_sym ] = value . empty? ? DEFAULT_PARAM_TYPE : value
64- end
65- end
66-
67- # Iterates over namespaces recursively
68- # to build a hash of path params with options, including type
69- def get_path_params ( stackable_values )
70- params = { }
71- return param unless stackable_values
72- return params unless stackable_values . is_a? Grape ::Util ::StackableValues
73-
74- stackable_values &.new_values &.dig ( :namespace ) &.each do |namespace | # rubocop:disable Style/SafeNavigationChainLength
75- space = namespace . space . to_s . gsub ( ':' , '' )
76- params [ space ] = namespace . options || { }
59+ defined_options = definition . is_a? ( Hash ) ? definition : { }
60+ value = ( path_params [ param ] || { } ) . merge ( defined_options )
61+ accum [ key ] = value . empty? ? DEFAULT_PARAM_TYPE : value
7762 end
78- inherited_params = get_path_params ( stackable_values . inherited_values )
79- inherited_params . merge ( params )
8063 end
8164 end
8265 end
0 commit comments