Class: R2OAS::Schema::V3::PathSqueezer

Inherits:
BaseSqueezer show all
Defined in:
lib/r2-oas/schema/v3/squeezer/path_squeezer.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 BaseSqueezer

#initialize

Methods inherited from Base

#support_components_objects

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from R2OAS::Schema::V3::BaseSqueezer

Instance Method Details

#squeeze_docsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/r2-oas/schema/v3/squeezer/path_squeezer.rb', line 12

def squeeze_docs
  slice_paths_schema = @schema_data['paths'].each_with_object({}) do |(path, data_when_path), result|
    data_when_path.each do |verb_or_not, data_when_verb_or_not|
      if VERB.include?(verb_or_not)
        include_tag_name = data_when_verb_or_not['tags'].first.in? @tag_names
        result.deep_merge!(path.to_s => data_when_path) if include_tag_name
      elsif NOT_VERB.include?(verb_or_not)
        result.deep_merge!(path.to_s => data_when_path)
      end
    end
  end
  { 'paths' => slice_paths_schema }
end