Sha256: 3eb9f78dc82c3a66596ad6feb25f0a8b191c3548173dec7b4b15c8b3f25b7a95
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true module GrapeSwagger module DocMethods class PathString class << self def build(route, options = {}) path = route.path.dup # always removing format path.sub!(/\(\.\w+?\)$/, '') path.sub!('(.:format)', '') # ... format path params path.gsub!(/:(\w+)/, '{\1}') # set item from path, this could be used for the definitions object item = path.gsub(%r{/{(.+?)}}, '').split('/').last.singularize.underscore.camelize || 'Item' if route.version && options[:add_version] version = GrapeSwagger::DocMethods::Version.get(route) version = version.first while version.is_a?(Array) path.sub!('{version}', version.to_s) else path.sub!('/{version}', '') end path = "#{OptionalObject.build(:base_path, options)}#{path}" if options[:add_base_path] [item, path.start_with?('/') ? path : "/#{path}"] end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems