class Apipie::Generator::Swagger::PathDecorator

Public Instance Methods

param?(param_name) click to toggle source

@param [Symbol] param_name

# File lib/apipie/generator/swagger/path_decorator.rb, line 7
def param?(param_name)
  param_names.include?(param_name)
end
param_names() click to toggle source
# File lib/apipie/generator/swagger/path_decorator.rb, line 2
def param_names
  @param_names ||= scan(/:(\w+)/).map { |ar| ar[0].to_sym }
end
swagger_path(controller_method = nil) click to toggle source

@param [String] controller_method

@return [Apipie::Generator::Swagger::PathDecorator]

# File lib/apipie/generator/swagger/path_decorator.rb, line 14
def swagger_path(controller_method = nil)
  current_path = gsub(/:(\w+)/, '{\1}').gsub(%r{/$}, '')

  unless current_path.starts_with?('/')
    warn_for_missing_slash(controller_method) if controller_method.present?

    current_path = "/#{current_path}"
  end

  current_path
end

Private Instance Methods

warn_for_missing_slash(controller_method) click to toggle source

@param [String] controller_method

# File lib/apipie/generator/swagger/path_decorator.rb, line 29
def warn_for_missing_slash(controller_method)
  Apipie::Generator::Swagger::Warning.for_code(
    Apipie::Generator::Swagger::Warning::ADDED_MISSING_SLASH_CODE,
    controller_method,
    { path: self }
  ).warn_through_writer
end