8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/openapi_parser/parameter_validator.rb', line 8
def validate_parameter(parameters_hash, params, object_reference, options, = false)
no_exist_required_key = []
params_key_converted = params.keys.map { |k| [convert_key(k, ), k] }.to_h
parameters_hash.each do |k, v|
key = params_key_converted[convert_key(k, )]
if params.include?(key)
coerced = v.validate_params(params[key], options)
params[key] = coerced if options.coerce_value
elsif v.required
no_exist_required_key << k
end
end
raise OpenAPIParser::NotExistRequiredKey.new(no_exist_required_key, object_reference) unless no_exist_required_key.empty?
params
end
|