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