lib/r2-oas/schema/v3/generator/components/object_generator.rb in r2-oas-0.1.3 vs lib/r2-oas/schema/v3/generator/components/object_generator.rb in r2-oas-0.2.0

- old
+ new

@@ -18,41 +18,21 @@ @components_objects = sorted_schema_data[@middle_category] @glob_schema_paths = create_glob_components_objects_paths end def generate_docs - if components_objects_file_do_not_exists? - logger.info ' <From routes data>' - generate_docs_from_routes_data - else - logger.info ' <From schema files>' - generate_docs_from_schema_fiels - end + logger.info ' <From routes data>' + generate_docs_from_routes_data end private alias components_objects_files_paths schema_files_paths - alias components_objects_file_do_not_exists? schema_file_do_not_exists? - def generate_docs_from_schema_fiels - components_schemas_from_schema_files = components_objects_files_paths.each_with_object({}) do |path, data| - yaml = YAML.load_file(path) - data.deep_merge!(yaml) - full_path = File.expand_path(path, './') - logger.info " Fetch Components schema file: \t#{full_path}" - end - @components_objects.deep_merge!(components_schemas_from_schema_files[@major_category][@middle_category]) - - process_when_generate_docs do |save_file_path| - logger.info " Merge schema file: \t#{save_file_path}" - end - end - def generate_docs_from_routes_data process_when_generate_docs do |save_file_path| - logger.info " Write schema file: \t#{save_file_path}" + logger.info " Add schema file into store: \t#{save_file_path}" end end def process_when_generate_docs logger.info " <Update Components schema files (#{@major_category}/#{@middle_category})>" @@ -63,12 +43,13 @@ } } relative_path = "#{@major_category}/#{@middle_category}/#{schema_name}" file_manager = ComponentsFileManager.build(relative_path, :relative) - file_manager.save(result.to_yaml) unless file_manager.skip_save? + save_file_path = file_manager.save_file_path(type: :relative) + store.add(save_file_path, result.to_yaml) - yield file_manager.save_file_path(type: :relative) if block_given? + yield save_file_path if block_given? end end def create_glob_components_objects_paths many_components_file_paths.select do |file_path|