From 2930c2f27d0d68edd8c6561bbfe60bdb851f13e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Nowak?= Date: Fri, 1 Mar 2024 11:34:40 +0100 Subject: [PATCH] check for not wrapping enums with allOf --- PropertyDescriber/ObjectPropertyDescriber.php | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/PropertyDescriber/ObjectPropertyDescriber.php b/PropertyDescriber/ObjectPropertyDescriber.php index 58cea138e..b27d2cfd9 100644 --- a/PropertyDescriber/ObjectPropertyDescriber.php +++ b/PropertyDescriber/ObjectPropertyDescriber.php @@ -36,22 +36,13 @@ public function describe(array $types, OA\Schema $property, array $groups = null $types[0]->getCollectionValueType() ); // ignore nullable field -// if ($types[0]->isNullable()) { -// $weakContext = Util::createWeakContext($property->_context); -// $schemas = [new OA\Schema(['ref' => $this->modelRegistry->register(new Model($type, $groups, null, $context)), '_context' => $weakContext])]; -// -// if ( -// function_exists('enum_exists') -// && enum_exists($type->getClassName()) -// && version_compare($weakContext->version, OA\OpenApi::VERSION_3_1_0, '<') -// ) { -// $property->allOf = $schemas; -// } else { -// $property->oneOf = $schemas; -// } -// -// return; -// } + if ($types[0]->isNullable()) { + $weakContext = Util::createWeakContext($property->_context); + $schemas = [new OA\Schema(['ref' => $this->modelRegistry->register(new Model($type, $groups, null, $context)), '_context' => $weakContext])]; + $property->oneOf = $schemas; + + return; + } $property->ref = $this->modelRegistry->register(new Model($type, $groups, null, $context)); }