5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/grape-swagger/doc_methods/path_string.rb', line 5
def build(route, options = {})
path = route.path
path.sub!(/\(\.\w+?\)$/, '')
path.sub!('(.:format)', '')
path.gsub!(/:(\w+)/, '{\1}')
item = path.gsub(%r{/{(.+?)}}, '').split('/').last.singularize.underscore.camelize || 'Item'
if route.version && options[:add_version]
path.sub!('{version}', route.version.to_s)
else
path.sub!('/{version}', '')
end
path = "#{GrapeSwagger::DocMethods::OptionalObject.build(:base_path, options)}#{path}" if options[:add_base_path]
[item, path.start_with?('/') ? path : "/#{path}"]
end
|