Sha256: 51d60c5503bdb89aceb362a196b091994468e559f0f8d897ba4ae3acf4cadff3

Contents?: true

Size: 962 Bytes

Versions: 12

Compression:

Stored size: 962 Bytes

Contents

# frozen_string_literal: true

require_relative 'base_squeezer'

module R2OAS
  module Schema
    module V3
      class PathSqueezer < BaseSqueezer
        VERB = %w[get put post delete options head patch trace].freeze
        NOT_VERB = %w[$ref summary description servers parameters].freeze

        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
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
r2-oas-0.5.0 lib/r2-oas/schema/v3/squeezer/path_squeezer.rb
r2-oas-0.4.1 lib/r2-oas/schema/v3/squeezer/path_squeezer.rb
r2-oas-0.4.0 lib/r2-oas/schema/v3/squeezer/path_squeezer.rb
r2-oas-0.3.4 lib/r2-oas/schema/v3/squeezer/path_squeezer.rb
r2-oas-0.3.3 lib/r2-oas/schema/v3/squeezer/path_squeezer.rb
r2-oas-0.3.2 lib/r2-oas/schema/v3/squeezer/path_squeezer.rb
r2-oas-0.3.1 lib/r2-oas/schema/v3/squeezer/path_squeezer.rb
r2-oas-0.3.0 lib/r2-oas/schema/v3/squeezer/path_squeezer.rb
r2-oas-0.2.0 lib/r2-oas/schema/v3/squeezer/path_squeezer.rb
r2-oas-0.1.3 lib/r2-oas/schema/v3/squeezer/path_squeezer.rb
r2-oas-0.1.2 lib/r2-oas/schema/v3/squeezer/path_squeezer.rb
r2-oas-0.1.0 lib/r2-oas/schema/v3/squeezer/path_squeezer.rb