Skip to content

Commit 874cbdb

Browse files
committed
feat(laravel): add max_errors config and pass it to validator
1 parent 25fc0e4 commit 874cbdb

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/Laravel/ValidatesOpenApiSchema.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Studio\OpenApiContractTesting\OpenApiCoverageTracker;
1111
use Studio\OpenApiContractTesting\OpenApiResponseValidator;
1212

13+
use function is_int;
1314
use function is_string;
1415
use function str_contains;
1516
use function strtolower;
@@ -51,7 +52,10 @@ protected function assertResponseMatchesOpenApiSchema(
5152

5253
$contentType = $response->headers->get('Content-Type', '');
5354

54-
$validator = new OpenApiResponseValidator();
55+
$maxErrors = config('openapi-contract-testing.max_errors', 20);
56+
$validator = new OpenApiResponseValidator(
57+
maxErrors: is_int($maxErrors) ? $maxErrors : 20,
58+
);
5559
$result = $validator->validate(
5660
$specName,
5761
$resolvedMethod,

src/Laravel/config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@
44

55
return [
66
'default_spec' => '',
7+
8+
// Maximum number of validation errors to report per response.
9+
// 0 = unlimited (reports all errors).
10+
'max_errors' => 20,
711
];

0 commit comments

Comments
 (0)