Module: Openapi3Parser::NodeFactory::ParameterLike

Included in:
Header, Parameter
Defined in:
lib/openapi3_parser/node_factory/parameter_like.rb

Instance Method Summary collapse

Instance Method Details

#content_factory(context) ⇒ Object



22
23
24
25
26
27
# File 'lib/openapi3_parser/node_factory/parameter_like.rb', line 22

def content_factory(context)
  NodeFactory::Map.new(context,
                       default: nil,
                       value_factory: NodeFactory::MediaType,
                       validate: method(:validate_content))
end

#default_explodeObject



6
7
8
# File 'lib/openapi3_parser/node_factory/parameter_like.rb', line 6

def default_explode
  context.input["style"] == "form"
end

#examples_factory(context) ⇒ Object



15
16
17
18
19
20
# File 'lib/openapi3_parser/node_factory/parameter_like.rb', line 15

def examples_factory(context)
  factory = NodeFactory::OptionalReference.new(NodeFactory::Example)
  NodeFactory::Map.new(context,
                       default: nil,
                       value_factory: factory)
end

#schema_factory(context) ⇒ Object



10
11
12
13
# File 'lib/openapi3_parser/node_factory/parameter_like.rb', line 10

def schema_factory(context)
  factory = NodeFactory::OptionalReference.new(NodeFactory::Schema)
  factory.call(context)
end

#validate_content(validatable) ⇒ Object



29
30
31
32
33
# File 'lib/openapi3_parser/node_factory/parameter_like.rb', line 29

def validate_content(validatable)
  return if validatable.input.size == 1

  validatable.add_error("Must only have one item")
end