lib/rspec_api_docs/after.rb in rspec-api-docs-0.8.0 vs lib/rspec_api_docs/after.rb in rspec-api-docs-0.9.0

- old
+ new

@@ -1,5 +1,7 @@ +# TODO: Move Resource out of formatter dir +require 'rspec_api_docs/formatter/resource' require 'rspec_api_docs/after/type_checker' module RspecApiDocs UndocumentedParameter = Class.new(BaseError) @@ -13,11 +15,14 @@ return unless RspecApiDocs.configuration.validate_params metadata[:requests].each do |request, response| request.params.each do |key, value| - if metadata[:parameters] && metadata[:parameters].has_key?(key.to_sym) - After::TypeChecker.call(type: metadata[:parameters][key.to_sym][:type], value: value) + parameter = RspecApiDocs::Resource::Example.new(example).parameters + .select { |parameter| parameter.name == key.to_sym }.first + + if parameter + After::TypeChecker.call(type: parameter.type, value: value) else raise UndocumentedParameter, "undocumented parameter included in request #{key.inspect}" end end end