class Openapi3Parser::Node::Object
Attributes
Public Class Methods
# File lib/openapi3_parser/node/object.rb, line 14 def initialize(data, context) @node_data = data @node_context = context end
Public Instance Methods
@param [Any] other
@return [Boolean]
# File lib/openapi3_parser/node/object.rb, line 54 def ==(other) other.instance_of?(self.class) && node_context.same_data_and_source?(other.node_context) end
Look up an attribute of the node by the name it has in the OpenAPI document.
@example Look up by OpenAPI naming
obj["externalDocs"]
@example Look up by symbol
obj[:servers]
@example Look up an extension
obj["x-myExtension"]
@param [String, Symbol] value
@return anything
# File lib/openapi3_parser/node/object.rb, line 34 def [](value) Placeholder.resolve(node_data[value.to_s]) end
Iterates through the data of this node, used by Enumerable
@return [Object]
# File lib/openapi3_parser/node/object.rb, line 62 def each(&block) Placeholder.each(node_data, &block) end
Look up an extension provided for this object, doesn't need a prefix of “x-”
@example Looking up an extension provided as “x-extra”
obj.extension("extra")
@param [String, Symbol] value
@return [Hash, Array
, Numeric, String, true, false, nil]
# File lib/openapi3_parser/node/object.rb, line 47 def extension(value) self["x-#{value}"] end
@return [String]
# File lib/openapi3_parser/node/object.rb, line 99 def inspect fragment = node_context.document_location.pointer.fragment %{#{self.class.name}(#{fragment})} end
Used to access a node relative to this node
@example Looking up the parent node of this node
obj.node_at("#..")
@example Jumping way down the tree
obj.node_at("#properties/Field/type")
@param [Source::Pointer, ::Array, ::String] pointer_like @return anything
# File lib/openapi3_parser/node/object.rb, line 93 def node_at(pointer_like) current_pointer = node_context.document_location.pointer node_context.document.node_at(pointer_like, current_pointer) end
Used to render fields that can be in markdown syntax into HTML @param [String, nil] value @return [String, nil]
# File lib/openapi3_parser/node/object.rb, line 77 def render_markdown(value) return if value.nil? Markdown.to_html(value) end
Provide an array of values for this object, a partner to the keys method
@return [Array]
# File lib/openapi3_parser/node/object.rb, line 70 def values map(&:last) end