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

- old
+ new

@@ -15,40 +15,19 @@ @docs = create_docs @options = options end def generate_docs - if force_update_schema || schema_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 - def create_docs - if !skip_generate_docs - super - elsif skip_generate_docs && FileTest.exists?(doc_save_file_path) - YAML.load_file(doc_save_file_path) - else - {} - end - end - private - def generate_docs_from_schema_fiels - 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 schema files>' @@ -64,10 +43,11 @@ logger.info ' [Generate OAS schema files (components)] start' ComponentsGenerator.new(result, @options).generate_docs logger.info ' [Generate OAS schema files (components)] end' else file_manager = FileManager.new(field_name, :relative) - file_manager.save(result.to_yaml) + 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? end end end