Module: Openapi3Parser::Node::Object

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#node_contextObject (readonly)

Returns the value of attribute node_context.



8
9
10
# File 'lib/openapi3_parser/node/object.rb', line 8

def node_context
  @node_context
end

#node_dataObject (readonly)

Returns the value of attribute node_data.



8
9
10
# File 'lib/openapi3_parser/node/object.rb', line 8

def node_data
  @node_data
end

Instance Method Details

#[](value) ⇒ Object

Look up an attribute of the node by the name it has in the OpenAPI document.

Examples:

Look up by OpenAPI naming

obj["externalDocs"]

Look up by symbol

obj[:servers]

Look up an extension

obj["x-myExtension"]

Parameters:

  • value (String, Symbol)

Returns:

  • anything



30
31
32
# File 'lib/openapi3_parser/node/object.rb', line 30

def [](value)
  node_data[value.to_s]
end

#each(&block) ⇒ Object

Iterate through the attributes of this object



48
49
50
# File 'lib/openapi3_parser/node/object.rb', line 48

def each(&block)
  node_data.each(&block)
end

#extension(value) ⇒ Hash, ...

Look up an extension provided for this object, doesn’t need a prefix of “x-”

Examples:

Looking up an extension provided as “x-extra”

obj.extension("extra")

Parameters:

  • value (String, Symbol)

Returns:

  • (Hash, Array, Numeric, String, true, false, nil)


43
44
45
# File 'lib/openapi3_parser/node/object.rb', line 43

def extension(value)
  node_data["x-#{value}"]
end

#initialize(data, context) ⇒ Object



10
11
12
13
# File 'lib/openapi3_parser/node/object.rb', line 10

def initialize(data, context)
  @node_data = data
  @node_context = context
end