From 4436c468f187ca92b7454a89a55970a2a069a3d8 Mon Sep 17 00:00:00 2001 From: Guilhem Niot Date: Sun, 27 Sep 2020 22:20:04 +0200 Subject: [PATCH] Fix the tests broken by zircote/swagger-php --- ModelDescriber/JMSModelDescriber.php | 10 +++++++++- Tests/Functional/JMSFunctionalTest.php | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ModelDescriber/JMSModelDescriber.php b/ModelDescriber/JMSModelDescriber.php index 1e77672..c81519a 100644 --- a/ModelDescriber/JMSModelDescriber.php +++ b/ModelDescriber/JMSModelDescriber.php @@ -263,7 +263,15 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn $groups = $this->computeGroups($context, $type); $model = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, $type['name']), $groups); - $property->ref = $this->modelRegistry->register($model); + $modelRef = $this->modelRegistry->register($model); + + $customFields = (array) $property->jsonSerialize(); + unset($customFields['property']); + if (empty($customFields)) { // no custom fields + $property->ref = $modelRef; + } else { + $property->allOf = [new OA\Schema(['ref' => $modelRef])]; + } $this->contexts[$model->getHash()] = $context; $this->metadataStacks[$model->getHash()] = clone $context->getMetadataStack(); diff --git a/Tests/Functional/JMSFunctionalTest.php b/Tests/Functional/JMSFunctionalTest.php index 7940726..14bd468 100644 --- a/Tests/Functional/JMSFunctionalTest.php +++ b/Tests/Functional/JMSFunctionalTest.php @@ -146,11 +146,11 @@ class JMSFunctionalTest extends WebTestCase ], 'virtual_type1' => [ 'title' => 'JMS custom types handled via Custom Type Handlers.', - '$ref' => '#/components/schemas/VirtualTypeClassDoesNotExistsHandlerDefined', + 'allOf' => [['$ref' => '#/components/schemas/VirtualTypeClassDoesNotExistsHandlerDefined']], ], 'virtual_type2' => [ 'title' => 'JMS custom types handled via Custom Type Handlers.', - '$ref' => '#/components/schemas/VirtualTypeClassDoesNotExistsHandlerNotDefined', + 'allOf' => [['$ref' => '#/components/schemas/VirtualTypeClassDoesNotExistsHandlerNotDefined']], ], 'last_update' => [ 'type' => 'date',