File tree Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -371,15 +371,15 @@ def get_path_params(stackable_values)
371
371
return params unless stackable_values . is_a? Grape ::Util ::StackableValues
372
372
stackable_values &.new_values [ :namespace ] &.each do |namespace |
373
373
space = namespace . space . to_s . gsub ( ':' , '' )
374
- params [ space ] = ( namespace . options || { } ) . merge ( required : true )
374
+ params [ space ] = namespace . options || { }
375
375
end
376
376
inherited_params = get_path_params ( stackable_values . inherited_values )
377
377
inherited_params . merge ( params )
378
378
end
379
379
380
380
def default_type ( params )
381
381
default_param_type = { required : true , type : 'Integer' }
382
- params . each { |param | param [ -1 ] = param . last == '' ? default_param_type : param . last }
382
+ params . each { |param | param [ -1 ] = param . last . empty? ? default_param_type : param . last }
383
383
end
384
384
385
385
def expose_params ( value )
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe '#833 route_param type is included in documentation' do
6
+ let ( :app ) do
7
+ Class . new ( Grape ::API ) do
8
+ resource :accounts do
9
+ route_param :account_number , type : String do
10
+ resource :records do
11
+ route_param :id do
12
+ get do
13
+ { message : 'hello world' }
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ add_swagger_documentation
21
+ end
22
+ end
23
+ let ( :parameters ) { subject [ 'paths' ] [ '/accounts/{account_number}/records/{id}' ] [ 'get' ] [ 'parameters' ] }
24
+
25
+ subject do
26
+ get '/swagger_doc'
27
+ JSON . parse ( last_response . body )
28
+ end
29
+
30
+ specify do
31
+ account_number_param = parameters . find { |param | param [ 'name' ] == 'account_number' }
32
+ expect ( account_number_param [ 'type' ] ) . to eq 'string'
33
+ id_param = parameters . find { |param | param [ 'name' ] == 'id' }
34
+ # Default is still integer
35
+ expect ( id_param [ 'type' ] ) . to eq 'integer'
36
+ end
37
+ end
You can’t perform that action at this time.
0 commit comments