-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from ckdot/master
Keep inner exceptions if oneOf or anyOf fails
- Loading branch information
Showing
4 changed files
with
118 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace League\OpenAPIValidation\Schema\Exception; | ||
|
||
use Throwable; | ||
|
||
class NotEnoughValidSchemas extends KeywordMismatch | ||
{ | ||
/** @var Throwable[] */ | ||
protected $innerExceptions = []; | ||
|
||
/** | ||
* @param mixed $data | ||
* @param Throwable[] $innerExceptions | ||
* | ||
* @return self | ||
*/ | ||
public static function fromKeywordWithInnerExceptions( | ||
string $keyword, | ||
$data, | ||
array $innerExceptions, | ||
?string $message = null | ||
) : KeywordMismatch { | ||
$instance = new self('Keyword validation failed: ' . $message, 0); | ||
$instance->keyword = $keyword; | ||
$instance->data = $data; | ||
$instance->innerExceptions = $innerExceptions; | ||
|
||
return $instance; | ||
} | ||
|
||
/** | ||
* @return Throwable[] | ||
*/ | ||
public function innerExceptions() : array | ||
{ | ||
return $this->innerExceptions; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace League\OpenAPIValidation\Schema\Exception; | ||
|
||
use cebe\openapi\spec\Schema; | ||
|
||
class TooManyValidSchemas extends KeywordMismatch | ||
{ | ||
/** @var Schema[] */ | ||
protected $validSchemas = []; | ||
|
||
/** | ||
* @param mixed $data | ||
* @param Schema[] $validSchemas | ||
* | ||
* @return self | ||
*/ | ||
public static function fromKeywordWithValidSchemas( | ||
string $keyword, | ||
$data, | ||
array $validSchemas, | ||
?string $message = null | ||
) : KeywordMismatch { | ||
$instance = new self('Keyword validation failed: ' . $message, 0); | ||
$instance->keyword = $keyword; | ||
$instance->data = $data; | ||
$instance->validSchemas = $validSchemas; | ||
|
||
return $instance; | ||
} | ||
|
||
/** | ||
* @return Schema[] | ||
*/ | ||
public function validSchemas() : array | ||
{ | ||
return $this->validSchemas; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters