Show the response body for comparison when schema checks fail

This commit is contained in:
mynnx 2021-03-03 16:32:16 -08:00
parent 0aca50c66c
commit a34c931bb6

View File

@ -50,7 +50,11 @@ module Rswag
.merge(schemas)
errors = JSON::Validator.fully_validate(validation_schema, body)
raise UnexpectedResponse, "Expected response body to match schema: #{errors[0]}" if errors.any?
return unless errors.any?
raise UnexpectedResponse,
"Expected response body to match schema: #{errors[0]}\n" \
"Response body: #{JSON.pretty_generate(JSON.parse(body))}"
end
def definitions_or_component_schemas(swagger_doc, version)