Fix the tests broken by zircote/swagger-php

This commit is contained in:
Guilhem Niot 2020-09-27 22:20:04 +02:00
parent 416d1f2d2a
commit 4436c468f1
2 changed files with 11 additions and 3 deletions

View File

@ -263,7 +263,15 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
$groups = $this->computeGroups($context, $type); $groups = $this->computeGroups($context, $type);
$model = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, $type['name']), $groups); $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->contexts[$model->getHash()] = $context;
$this->metadataStacks[$model->getHash()] = clone $context->getMetadataStack(); $this->metadataStacks[$model->getHash()] = clone $context->getMetadataStack();

View File

@ -146,11 +146,11 @@ class JMSFunctionalTest extends WebTestCase
], ],
'virtual_type1' => [ 'virtual_type1' => [
'title' => 'JMS custom types handled via Custom Type Handlers.', 'title' => 'JMS custom types handled via Custom Type Handlers.',
'$ref' => '#/components/schemas/VirtualTypeClassDoesNotExistsHandlerDefined', 'allOf' => [['$ref' => '#/components/schemas/VirtualTypeClassDoesNotExistsHandlerDefined']],
], ],
'virtual_type2' => [ 'virtual_type2' => [
'title' => 'JMS custom types handled via Custom Type Handlers.', 'title' => 'JMS custom types handled via Custom Type Handlers.',
'$ref' => '#/components/schemas/VirtualTypeClassDoesNotExistsHandlerNotDefined', 'allOf' => [['$ref' => '#/components/schemas/VirtualTypeClassDoesNotExistsHandlerNotDefined']],
], ],
'last_update' => [ 'last_update' => [
'type' => 'date', 'type' => 'date',