Module: OpenapiRspec::Helpers

Defined in:
lib/openapi_rspec/helpers.rb

Instance Method Summary collapse

Instance Method Details

#path_params(path) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/openapi_rspec/helpers.rb', line 20

def path_params(path)
  path_params = {}
  path.scan(/\{([^}]*)\}/).each do |param|
    key = param.first.to_sym
    path_params[key] = public_send(key) if respond_to?(key)
  end
  path_params
end

#request_params(metadata) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/openapi_rspec/helpers.rb', line 5

def request_params()
  path = defined?(uri) ? uri : [:uri]
  method = defined?(http_method) ? http_method : [:method]

  {
    method: method,
    path: path,
    params: openapi_rspec_params,
    path_params: path_params(path),
    headers: openapi_rspec_headers,
    query: openapi_rspec_query,
    media_type: openapi_rspec_media_type
  }
end