mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
Fix the Util class manipulation of array of objects (#1653)
* Fix the Util class manipulation of array of objects * fix cs
This commit is contained in:
parent
d932b06bbb
commit
3623bdb1ea
@ -455,11 +455,27 @@ final class Util
|
|||||||
private static function mergeTyped(OA\AbstractAnnotation $annotation, $propertyName, $type, array $properties, array $defaults, bool $overwrite)
|
private static function mergeTyped(OA\AbstractAnnotation $annotation, $propertyName, $type, array $properties, array $defaults, bool $overwrite)
|
||||||
{
|
{
|
||||||
if (\is_string($type) && 0 === strpos($type, '[')) {
|
if (\is_string($type) && 0 === strpos($type, '[')) {
|
||||||
/* type is declared as array in @see OA\AbstractAnnotation::$_types */
|
$innerType = substr($type, 1, -1);
|
||||||
$annotation->{$propertyName} = array_unique(array_merge(
|
|
||||||
$annotation->{$propertyName} && UNDEFINED !== $annotation->{$propertyName} ? $annotation->{$propertyName} : [],
|
if (!$annotation->{$propertyName} || UNDEFINED === $annotation->{$propertyName}) {
|
||||||
$properties[$propertyName]
|
$annotation->{$propertyName} = [];
|
||||||
));
|
}
|
||||||
|
|
||||||
|
if (!class_exists($innerType)) {
|
||||||
|
/* type is declared as array in @see OA\AbstractAnnotation::$_types */
|
||||||
|
$annotation->{$propertyName} = array_unique(array_merge(
|
||||||
|
$annotation->{$propertyName},
|
||||||
|
$properties[$propertyName]
|
||||||
|
));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $type == [Schema] for instance
|
||||||
|
foreach ($properties[$propertyName] as $child) {
|
||||||
|
$annotation->{$propertyName}[] = $annot = self::createChild($annotation, $innerType, []);
|
||||||
|
self::merge($annot, $child, $overwrite);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self::mergeProperty($annotation, $propertyName, $properties[$propertyName], $defaults[$propertyName], $overwrite);
|
self::mergeProperty($annotation, $propertyName, $properties[$propertyName], $defaults[$propertyName], $overwrite);
|
||||||
}
|
}
|
||||||
|
@ -176,6 +176,17 @@ class TestKernel extends Kernel
|
|||||||
'Test' => [
|
'Test' => [
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// Ensures https://github.com/nelmio/NelmioApiDocBundle/issues/1650 is working
|
||||||
|
'Pet' => [
|
||||||
|
'type' => 'object',
|
||||||
|
],
|
||||||
|
'Cat' => [
|
||||||
|
'allOf' => [
|
||||||
|
['$ref' => '#/components/schemas/Pet'],
|
||||||
|
['type' => 'object'],
|
||||||
|
],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'parameters' => [
|
'parameters' => [
|
||||||
'test' => [
|
'test' => [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user