module OpenAPIParser::Findable
Public Instance Methods
find_object(reference)
click to toggle source
@param [String] reference @return [OpenAPIParser::Findable]
# File lib/openapi_parser/concerns/findable.rb, line 7 def find_object(reference) return self if object_reference == reference remote_reference = !reference.start_with?('#') return find_remote_object(reference) if remote_reference return nil unless reference.start_with?(object_reference) unescaped_reference = CGI.unescape(reference) @find_object_cache = {} unless defined? @find_object_cache if (obj = @find_object_cache[unescaped_reference]) return obj end if (child = _openapi_all_child_objects[unescaped_reference]) @find_object_cache[unescaped_reference] = child return child end _openapi_all_child_objects.values.each do |c| if (obj = c.find_object(unescaped_reference)) @find_object_cache[unescaped_reference] = obj return obj end end nil end
purge_object_cache()
click to toggle source
# File lib/openapi_parser/concerns/findable.rb, line 35 def purge_object_cache @purged = false unless defined? @purged return if @purged @find_object_cache = {} @purged = true _openapi_all_child_objects.values.each(&:purge_object_cache) end
Private Instance Methods
find_remote_object(reference)
click to toggle source
# File lib/openapi_parser/concerns/findable.rb, line 48 def find_remote_object(reference) reference_uri = URI(reference) fragment = reference_uri.fragment reference_uri.fragment = nil root.load_another_schema(reference_uri)&.find_object("##{fragment}") end