Class: R2OAS::Schema::V3::PathAnalyzer

Inherits:
BaseAnalyzer show all
Defined in:
lib/r2-oas/schema/v3/analyzer/path_analyzer.rb

Constant Summary collapse

VERB =
%w[get put post delete options head patch trace].freeze
NOT_VERB =
%w[$ref summary description servers parameters].freeze

Constants inherited from Base

Base::SUPPORT_COMPONENTS_OBJECTS

Instance Method Summary collapse

Methods inherited from BaseAnalyzer

#generate_from_existing_schema

Methods included from R2OAS::Sortable

#deep_sort

Methods inherited from Base

#support_components_objects

Constructor Details

#initialize(before_schema_data, after_schema_data, options = {}) ⇒ PathAnalyzer

Returns a new instance of PathAnalyzer.



16
17
18
19
# File 'lib/r2-oas/schema/v3/analyzer/path_analyzer.rb', line 16

def initialize(before_schema_data, after_schema_data, options = {})
  super
  @tags = []
end

Instance Method Details

#analyze_docsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/r2-oas/schema/v3/analyzer/path_analyzer.rb', line 21

def analyze_docs
  sorted_schema = deep_sort(@after_schema_data, 'paths')
  edited_paths_schema = sorted_schema['paths']

  save_each_tags(edited_paths_schema) do |tag_name, result|
    file_manager = PathItemFileManager.new("paths/#{tag_name}", :relative)
    file_manager.save(result.to_yaml)
    logger.info "  Write schema file: \t#{file_manager.save_file_path(type: :relative)}"
  end

  # Automatically generated when there is no tag object in the read schema file
  if generate_tag_file?
    result = { 'tags' => V3::TagObject.new(@tags).to_doc }
    file_manager = FileManager.new('tags', :relative)
    file_manager.save(result.to_yaml)
  end
end