Module: Skooma::Objects::Parameter::Keywords::ValueParser

Defined in:
lib/skooma/objects/parameter/keywords/value_parser.rb

Constant Summary collapse

ARRAY_STYLE_DELIMITERS =
{
  "form" => ",",
  "simple" => ",",
  "spaceDelimited" => " ",
  "pipeDelimited" => "|"
}.freeze
DEFAULT_STYLE =

Default ‘style` per parameter location (OpenAPI 3.1 parameter object).

{
  "query" => "form",
  "path" => "simple",
  "header" => "simple",
  "cookie" => "form"
}.freeze

Class Method Summary collapse

Class Method Details

.call(instance, result, schema: nil) ⇒ Object

Raises:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/skooma/objects/parameter/keywords/value_parser.rb', line 27

def call(instance, result, schema: nil)
  location = result.sibling(instance, "in")&.annotation
  raise Error, "Missing `in` key #{result.path}" unless location

  key = result.sibling(instance, "name")&.annotation
  raise Error, "Missing `name` key #{result.path}" unless key

  case location
  when "query"
    query_param_value(instance, result, key, schema: schema)
  when "header"
    header_param_value(instance, result, key, schema: schema)
  when "path"
    path_param_value(instance, result, key, schema: schema)
  when "cookie"
    cookie_param_value(instance, result, key, schema: schema)
  else
    raise Error, "Unknown location: #{location}"
  end
end