Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Test/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,19 @@ public function validateOpenApiSchema(): void
$validator = new ResponseValidator($this->specification->getDocument());
$validator->validate($operationAddress, $this->response);
} catch (ValidationFailed $e) {
$exception = $e->getPrevious();
$previous = $e->getPrevious();

if ($exception instanceof SchemaMismatch) {
if ($previous instanceof SchemaMismatch) {
$breadcrumb = implode(
'.',
$exception->dataBreadCrumb() !== null ? $exception->dataBreadCrumb()
$previous->dataBreadCrumb() !== null ? $previous->dataBreadCrumb()
->buildChain() : []
);
$message = sprintf('Invalid field: %s. %s', $breadcrumb, $exception->getMessage());
$message = sprintf('Invalid field: %s. %s', $breadcrumb, $previous->getMessage());
}
throw new InvalidResponseSchemaException(
$message ??
sprintf('Response schema validation failed: %s', $exception?->getMessage()),
sprintf('Response schema validation failed: %s', $e->getMessage()),
0,
$e
);
Expand Down
2 changes: 1 addition & 1 deletion tests/Test/TestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function testWrongEnum(): void
$this->testCase->assert();
}

public function testNullRequiredPropertyWithSchemaValidationShouldFail(): void
public function testIntInsteadOfStringShouldThrowInvalidSchemaException(): void
{
$this->expectException(InvalidResponseSchemaException::class);

Expand Down