From 8ede7f78f15f9572e8a4e16ebae8c7813c34c336 Mon Sep 17 00:00:00 2001 From: Hannes Probst Date: Tue, 18 Jul 2017 12:29:50 +0200 Subject: [PATCH] use fully_validate to get more specific error msg --- rswag-specs/lib/rswag/specs/response_validator.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/rswag-specs/lib/rswag/specs/response_validator.rb b/rswag-specs/lib/rswag/specs/response_validator.rb index 7194953..30a8ec8 100644 --- a/rswag-specs/lib/rswag/specs/response_validator.rb +++ b/rswag-specs/lib/rswag/specs/response_validator.rb @@ -40,13 +40,12 @@ module Rswag response_schema = @api_metadata[:response][:schema] return if response_schema.nil? - begin - validation_schema = response_schema - .merge('$schema' => 'http://tempuri.org/rswag/specs/extended_schema') - .merge(@global_metadata.slice(:definitions)) - JSON::Validator.validate!(validation_schema, body) - rescue JSON::Schema::ValidationError => ex - raise UnexpectedResponse, "Expected response body to match schema: #{ex.message}" + validation_schema = response_schema + .merge('$schema' => 'http://tempuri.org/rswag/specs/extended_schema') + .merge(@global_metadata.slice(:definitions)) + error_messages = JSON::Validator.fully_validate(validation_schema, body) + if error_messages.any? + raise UnexpectedResponse, "Expected response body to match schema: #{error_messages[0]}" end end end