class R2OAS::Schema::V3::IncludeRefBaseFileManager
Constants
- REF
Attributes
parent_save_file_paths[RW]
recursive_search_class[RW]
Public Class Methods
new(path, path_type = :ref)
click to toggle source
Calls superclass method
R2OAS::Schema::V3::BaseFileManager::new
# File lib/r2-oas/schema/v3/manager/file/include_ref_base_file_manager.rb, line 12 def initialize(path, path_type = :ref) super @convert_underscore_to_slash = true @parent_save_file_paths = [] @recursive_search_class = self.class end
Also aliased as: build
Public Instance Methods
descendants_paths()
click to toggle source
# File lib/r2-oas/schema/v3/manager/file/include_ref_base_file_manager.rb, line 23 def descendants_paths results = [] deep_search_ref_recursive(load_data) do |relative_paths| results.push(*relative_paths) end results.uniq end
Also aliased as: descendants_ref_paths
Private Instance Methods
deep_search_ref_recursive(yaml, &block)
click to toggle source
# File lib/r2-oas/schema/v3/manager/file/include_ref_base_file_manager.rb, line 38 def deep_search_ref_recursive(yaml, &block) case yaml when Hash yaml.each do |key, value| process_deep_search_ref_recursive(key, value, &block) end # Support allOf/oneOf/anyOf when Array yaml.each do |el| next unless el.is_a?(Hash) el.each do |key, value| process_deep_search_ref_recursive(key, value, &block) end end end end
process_deep_search_ref_recursive(ref_key_or_not, ref_value_or_not) { |results| ... }
click to toggle source
# File lib/r2-oas/schema/v3/manager/file/include_ref_base_file_manager.rb, line 56 def process_deep_search_ref_recursive(ref_key_or_not, ref_value_or_not, &block) # Don't pick up JSON Schema $ref # e.x.) # $ref: { "type" => "string" } if (ref_key_or_not.eql? REF) && ref_value_or_not.to_s.start_with?('#/') # Avoid $ ref circular references pm = PathnameManager.new(ref_value_or_not, :ref) relative_save_file_path = pm.relative_save_file_path if @parent_save_file_paths.include?(relative_save_file_path) return else @parent_save_file_paths.push(relative_save_file_path) end child_file_manager = @recursive_search_class.build(ref_value_or_not, :ref) child_load_data = child_file_manager.load_data children_paths = [] deep_search_ref_recursive(child_load_data) do |children_path| children_paths.push(*children_path) end results = [child_file_manager.save_file_path] + children_paths yield results if block_given? else deep_search_ref_recursive(ref_value_or_not, &block) end end