for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Nicofuma\SwaggerBundle\Validator;
use FR3D\SwaggerAssertions\PhpUnit\SymfonyAssertsTrait;
use FR3D\SwaggerAssertions\SchemaManager;
use JsonSchema\Constraints\Factory;
use Symfony\Component\HttpFoundation\Request;
class Validator
{
use SymfonyAssertsTrait;
/** @var SchemaManager */
private $schemaManager;
/** @var bool */
private $strict;
/** @var Factory */
private $constraintsFactory;
public function __construct(Factory $constraintsFactory, SchemaManager $schemaManager, $strict)
$this->schemaManager = $schemaManager;
$this->strict = $strict;
$this->constraintsFactory = $constraintsFactory;
}
public function validate(Request $request)
try {
$this->assertRequestMatch($request, $this->schemaManager);
} catch (\RuntimeException $e) {
if ($this->strict || $e->getMessage() !== 'Request URI does not match with any swagger path definition') {
throw $e;
/**
* @return SchemaManager
*/
public function getSchemaManager()
return $this->schemaManager;
* {@inheritdoc}
protected function getValidator()
return new \JsonSchema\Validator($this->constraintsFactory);
$this->constraintsFactory
object<JsonSchema\Constraints\Factory>
integer
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: