mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Fix additionalProperties support
This commit is contained in:
parent
40dfcf4184
commit
ee00f02a48
@ -346,10 +346,17 @@ final class Util
|
|||||||
{
|
{
|
||||||
$done = [];
|
$done = [];
|
||||||
|
|
||||||
|
$defaults = \get_class_vars(\get_class($annotation));
|
||||||
|
|
||||||
foreach ($annotation::$_nested as $className => $propertyName) {
|
foreach ($annotation::$_nested as $className => $propertyName) {
|
||||||
if (\is_string($propertyName)) {
|
if (\is_string($propertyName)) {
|
||||||
if (array_key_exists($propertyName, $properties)) {
|
if (array_key_exists($propertyName, $properties)) {
|
||||||
self::mergeChild($annotation, $className, $properties[$propertyName], $overwrite);
|
if (!is_bool($properties[$propertyName])) {
|
||||||
|
self::mergeChild($annotation, $className, $properties[$propertyName], $overwrite);
|
||||||
|
} elseif ($overwrite || $annotation->{$propertyName} === $defaults[$propertyName]) {
|
||||||
|
// Support for boolean values (for instance for additionalProperties)
|
||||||
|
$annotation->{$propertyName} = $properties[$propertyName];
|
||||||
|
}
|
||||||
$done[] = $propertyName;
|
$done[] = $propertyName;
|
||||||
}
|
}
|
||||||
} elseif (\array_key_exists($propertyName[0], $properties)) {
|
} elseif (\array_key_exists($propertyName[0], $properties)) {
|
||||||
@ -360,8 +367,6 @@ final class Util
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaults = \get_class_vars(\get_class($annotation));
|
|
||||||
|
|
||||||
foreach ($annotation::$_types as $propertyName => $type) {
|
foreach ($annotation::$_types as $propertyName => $type) {
|
||||||
if (array_key_exists($propertyName, $properties)) {
|
if (array_key_exists($propertyName, $properties)) {
|
||||||
self::mergeTyped($annotation, $propertyName, $type, $properties, $defaults, $overwrite);
|
self::mergeTyped($annotation, $propertyName, $type, $properties, $defaults, $overwrite);
|
||||||
|
@ -526,4 +526,11 @@ class FunctionalTest extends WebTestCase
|
|||||||
$this->getModel('SymfonyDiscriminatorOne');
|
$this->getModel('SymfonyDiscriminatorOne');
|
||||||
$this->getModel('SymfonyDiscriminatorTwo');
|
$this->getModel('SymfonyDiscriminatorTwo');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testNoAdditionalPropertiesSupport()
|
||||||
|
{
|
||||||
|
$model = $this->getModel('AddProp');
|
||||||
|
|
||||||
|
$this->assertFalse($model->additionalProperties);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,6 +198,10 @@ class TestKernel extends Kernel
|
|||||||
['type' => 'object'],
|
['type' => 'object'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'AddProp' => [
|
||||||
|
'type' => 'object',
|
||||||
|
'additionalProperties' => false,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'parameters' => [
|
'parameters' => [
|
||||||
'test' => [
|
'test' => [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user