Class: Apipie::Generator::Swagger::PathDecorator

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/apipie/generator/swagger/path_decorator.rb

Instance Method Summary collapse

Instance Method Details

#param?(param_name) ⇒ Boolean

Parameters:

  • param_name (Symbol)

Returns:

  • (Boolean)


7
8
9
# File 'lib/apipie/generator/swagger/path_decorator.rb', line 7

def param?(param_name)
  param_names.include?(param_name)
end

#param_namesObject



2
3
4
# 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) ⇒ Apipie::Generator::Swagger::PathDecorator

Parameters:

  • controller_method (String) (defaults to: nil)

Returns:



14
15
16
17
18
19
20
21
22
23
24
# 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