@@ -40,7 +40,8 @@ def self.setup(options)
40
40
:base_path => nil ,
41
41
:api_version => '0.1' ,
42
42
:markdown => false ,
43
- :hide_documentation_path => false
43
+ :hide_documentation_path => false ,
44
+ :hide_format => false
44
45
}
45
46
options = defaults . merge ( options )
46
47
@@ -49,6 +50,7 @@ def self.setup(options)
49
50
@@class_name = options [ :class_name ] || options [ :mount_path ] . gsub ( '/' , '' )
50
51
@@markdown = options [ :markdown ]
51
52
@@hide_documentation_path = options [ :hide_documentation_path ]
53
+ @@hide_format = options [ :hide_format ]
52
54
api_version = options [ :api_version ]
53
55
base_path = options [ :base_path ]
54
56
@@ -63,7 +65,7 @@ def self.setup(options)
63
65
end
64
66
65
67
routes_array = routes . keys . map do |local_route |
66
- { :path => "#{ parse_path ( route . route_path . gsub ( '(.:format)' , '' ) , route . route_version ) } /#{ local_route } .{format}" }
68
+ { :path => "#{ parse_path ( route . route_path . gsub ( '(.:format)' , '' ) , route . route_version ) } /#{ local_route } #{ @@hide_format ? '' : ' .{format}' } " }
67
69
end
68
70
{
69
71
apiVersion : api_version ,
@@ -158,17 +160,17 @@ def parse_header_params(params)
158
160
159
161
def parse_path ( path , version )
160
162
# adapt format to swagger format
161
- parsed_path = path . gsub ( '(.:format)' , '.{format}' )
163
+ parsed_path = path . gsub '(.:format)' , ( @@hide_format ? '' : '.{format}' )
162
164
# This is attempting to emulate the behavior of
163
165
# Rack::Mount::Strexp. We cannot use Strexp directly because
164
166
# all it does is generate regular expressions for parsing URLs.
165
167
# TODO: Implement a Racc tokenizer to properly generate the
166
168
# parsed path.
167
169
parsed_path = parsed_path . gsub ( /:([a-zA-Z_]\w *)/ , '{\1}' )
168
170
# add the version
169
- parsed_path = parsed_path . gsub ( '{version}' , version ) if version
170
- parsed_path
171
+ version ? parsed_path . gsub ( '{version}' , version ) : parsed_path
171
172
end
173
+
172
174
def parse_http_codes codes
173
175
codes ||= { }
174
176
codes . collect do |k , v |
0 commit comments