Sha256: 65aaa109b2535175a35cceb091146f57e72e790562e4962f3af2ee6e59fa2614
Contents?: true
Size: 899 Bytes
Versions: 7
Compression:
Stored size: 899 Bytes
Contents
# frozen_string_literal: true module Openapi3Parser module Validators class DuplicateParameters def self.call(resolved_input) new.call(resolved_input) end def call(resolved_input) dupes = duplicate_names_by_in(resolved_input) message(dupes) unless dupes.empty? end private def duplicate_names_by_in(resolved_input) potential_items = resolved_input.reject do |item| next true unless item.respond_to?(:keys) item["name"].nil? || item["in"].nil? end potential_items.group_by { |item| [item["name"], item["in"]] } .delete_if { |_, group| group.size < 2 } .keys end def message(dupes) grouped = dupes.map { |d| "#{d.first} in #{d.last}" }.join(", ") "Duplicate parameters: #{grouped}" end end end end
Version data entries
7 entries across 7 versions & 2 rubygems