lib/r2-oas/tasks/main.rake in r2-oas-0.1.3 vs lib/r2-oas/tasks/main.rake in r2-oas-0.2.0
- old
+ new
@@ -6,112 +6,105 @@
require 'r2-oas/task_logging'
load File.expand_path('common.rake', __dir__)
namespace :routes do
namespace :oas do
- desc 'Generate Swagger documentation files'
+ desc 'Generate OAS documentation files'
task docs: [:common] do
- logger.info '[R2-OAS] start'
- options = { unit_paths_file_path: unit_paths_file_path, skip_load_dot_paths: true }
- generator = R2OAS::Schema::Generator.new(options)
- generator.generate_docs
- logger.info '[R2-OAS] end'
+ start do
+ is_create_cache = cache_docs.eql? 'true'
+ options = { unit_paths_file_path: unit_paths_file_path, skip_load_dot_paths: true, is_create_cache: is_create_cache }
+ generator = R2OAS::Schema::Generator.new(options)
+ generator.generate_docs
+ end
end
- desc 'Analyze Swagger documentation'
+ desc 'Analyze OAS documentation'
task analyze: [:common] do
- logger.info '[R2-OAS] start'
+ start do
+ analyzer_options = { type: :existing, existing_schema_file_path: existing_schema_file_path }
+ analyzer = R2OAS::Schema::Analyzer.new({}, {}, analyzer_options)
+ analyzer.analyze_docs
- analyzer_options = { type: :existing, existing_schema_file_path: existing_schema_file_path }
- analyzer = R2OAS::Schema::Analyzer.new({}, {}, analyzer_options)
- analyzer.analyze_docs
-
- generator_options = { skip_generate_docs: true }
- generator = R2OAS::Schema::Generator.new(generator_options)
- generator.generate_docs
-
- logger.info '[R2-OAS] end'
+ builder_options = {}
+ builder = R2OAS::Schema::Builder.new(builder_options)
+ builder.build_docs
+ end
end
- desc 'Distribute Swagger documentation'
+ desc 'Distribute OAS documentation'
task dist: [:common] do
- logger.info '[R2-OAS] start'
-
- generator_options = { unit_paths_file_path: unit_paths_file_path, skip_generate_docs: true }
- generator = R2OAS::Schema::Generator.new(generator_options)
- generator.generate_docs
-
- logger.info '[R2-OAS] end'
+ start do
+ builder_options = { unit_paths_file_path: unit_paths_file_path }
+ builder = R2OAS::Schema::Builder.new(builder_options)
+ builder.build_docs
+ end
end
desc 'Open Swagger Editor'
task editor: [:common] do
- logger.info '[R2-OAS] start'
+ start do
+ builder_options = { unit_paths_file_path: unit_paths_file_path }
+ builder = R2OAS::Schema::Builder.new(builder_options)
+ builder.build_docs
- generator_options = { unit_paths_file_path: unit_paths_file_path, skip_generate_docs: true }
- generator = R2OAS::Schema::Generator.new(generator_options)
- generator.generate_docs
-
- before_schema_data = generator.oas_doc
- editor_options = { unit_paths_file_path: unit_paths_file_path }
- editor = R2OAS::Schema::Editor.new(before_schema_data, editor_options)
- editor.start
-
- logger.info '[R2-OAS] end'
+ before_schema_data = builder.oas_doc
+ editor_options = { unit_paths_file_path: unit_paths_file_path }
+ editor = R2OAS::Schema::Editor.new(before_schema_data, editor_options)
+ editor.start
+ end
end
desc 'Open Swagger UI'
task ui: [:common] do
- logger.info '[R2-OAS] start'
+ start do
+ builder_options = { unit_paths_file_path: unit_paths_file_path }
+ builder = R2OAS::Schema::Builder.new(builder_options)
+ builder.build_docs
- generator_options = { unit_paths_file_path: unit_paths_file_path, skip_generate_docs: true }
- generator = R2OAS::Schema::Generator.new(generator_options)
- generator.generate_docs
-
- ui_options = { unit_paths_file_path: unit_paths_file_path }
- ui = R2OAS::Schema::UI.new(ui_options)
- ui.start
-
- logger.info '[R2-OAS] end'
+ ui_options = { unit_paths_file_path: unit_paths_file_path }
+ ui = R2OAS::Schema::UI.new(ui_options)
+ ui.start
+ end
end
- desc 'Monitor Swagger Document'
+ desc 'Monitor OAS Document'
task monitor: [:common] do
- logger.info '[R2-OAS] start'
+ start do
+ builder_options = { unit_paths_file_path: unit_paths_file_path }
+ builder = R2OAS::Schema::Builder.new(builder_options)
+ builder.build_docs
- generator_options = { unit_paths_file_path: unit_paths_file_path, skip_generate_docs: true }
- generator = R2OAS::Schema::Generator.new(generator_options)
- generator.generate_docs
-
- before_schema_data = generator.oas_doc
- monitor_options = { unit_paths_file_path: unit_paths_file_path }
- monitor = R2OAS::Schema::Monitor.new(before_schema_data, monitor_options)
- monitor.start
-
- logger.info '[R2-OAS] end'
+ before_schema_data = builder.oas_doc
+ monitor_options = { unit_paths_file_path: unit_paths_file_path }
+ monitor = R2OAS::Schema::Monitor.new(before_schema_data, monitor_options)
+ monitor.start
+ end
end
- desc 'Clean Swagger Document'
+ desc 'Clean OAS Document'
task clean: [:common] do
- logger.info '[R2-OAS] start'
+ start do
+ builder_options = { skip_load_dot_paths: true }
+ builder = R2OAS::Schema::Builder.new(builder_options)
+ builder.build_docs
- generator_options = { skip_generate_docs: true, skip_load_dot_paths: true }
- generator = R2OAS::Schema::Generator.new(generator_options)
- generator.generate_docs
-
- cleaner = R2OAS::Schema::Cleaner.new
- cleaner.clean_docs
-
- logger.info '[R2-OAS] end'
+ cleaner = R2OAS::Schema::Cleaner.new
+ cleaner.clean_docs
+ end
end
private
def unit_paths_file_path
ENV.fetch('PATHS_FILE', '')
end
def existing_schema_file_path
ENV.fetch('OAS_FILE', '')
+ end
+
+ def cache_docs
+ ENV.fetch('CACHE_DOCS', 'false')
end
end
end