mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
Merge pull request #1447 from AyrtonRicardo/master
Change validation to allow fields described as DateTimeInterface.
This commit is contained in:
commit
0bca7f377d
@ -106,7 +106,7 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar
|
||||
$property->setType('number');
|
||||
$property->setFormat('float');
|
||||
} elseif (Type::BUILTIN_TYPE_OBJECT === $type->getBuiltinType()) {
|
||||
if (is_subclass_of($type->getClassName(), \DateTimeInterface::class)) {
|
||||
if (is_a($type->getClassName(), \DateTimeInterface::class, true)) {
|
||||
$property->setType('string');
|
||||
$property->setFormat('date-time');
|
||||
} else {
|
||||
|
@ -78,6 +78,11 @@ class User
|
||||
*/
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* @var \DateTimeInterface
|
||||
*/
|
||||
private $dateAsInterface;
|
||||
|
||||
/**
|
||||
* @param float $money
|
||||
*/
|
||||
@ -134,4 +139,20 @@ class User
|
||||
public function setStatus(string $status)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTimeInterface
|
||||
*/
|
||||
public function getDateAsInterface(): \DateTimeInterface
|
||||
{
|
||||
return $this->dateAsInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTimeInterface $dateAsInterface
|
||||
*/
|
||||
public function setDateAsInterface(\DateTimeInterface $dateAsInterface)
|
||||
{
|
||||
$this->dateAsInterface = $dateAsInterface;
|
||||
}
|
||||
}
|
||||
|
@ -220,6 +220,10 @@ class FunctionalTest extends WebTestCase
|
||||
'type' => 'string',
|
||||
'enum' => ['disabled', 'enabled'],
|
||||
],
|
||||
'dateAsInterface' => [
|
||||
'type' => 'string',
|
||||
'format' => 'date-time',
|
||||
],
|
||||
],
|
||||
],
|
||||
$this->getModel('User')->toArray()
|
||||
|
Loading…
x
Reference in New Issue
Block a user