Sha256: 7b766664db38bb936e866d7413502631a8e75316fc15b60be19eae7d90fb376c

Contents?: true

Size: 920 Bytes

Versions: 7

Compression:

Stored size: 920 Bytes

Contents

module GrapeSwagger
  module DocMethods
    class PathString
      class << self
        def build(route, options = {})
          path = route.path
          # 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]
            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
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
grape-swagger-0.25.2 lib/grape-swagger/doc_methods/path_string.rb
grape-swagger-0.25.1 lib/grape-swagger/doc_methods/path_string.rb
grape-swagger-0.25.0 lib/grape-swagger/doc_methods/path_string.rb
grape-swagger-0.24.0 lib/grape-swagger/doc_methods/path_string.rb
grape-swagger-0.23.0 lib/grape-swagger/doc_methods/path_string.rb
grape-swagger-0.22.0 lib/grape-swagger/doc_methods/path_string.rb
grape-swagger-0.21.0 lib/grape-swagger/doc_methods/path_string.rb