Skip to content

Commit 6cac88a

Browse files
author
Bartłomiej Nowak
committed
check for not wrapping enums with allOf
1 parent 35f2f01 commit 6cac88a

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

src/PropertyDescriber/ObjectPropertyDescriber.php

+7-16
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,13 @@ public function describe(array $types, OA\Schema $property, array $groups = null
3636
$types[0]->getCollectionValueType()
3737
); // ignore nullable field
3838

39-
// if ($types[0]->isNullable()) {
40-
// $weakContext = Util::createWeakContext($property->_context);
41-
// $schemas = [new OA\Schema(['ref' => $this->modelRegistry->register(new Model($type, $groups, null, $context)), '_context' => $weakContext])];
42-
//
43-
// if (
44-
// function_exists('enum_exists')
45-
// && enum_exists($type->getClassName())
46-
// && version_compare($weakContext->version, OA\OpenApi::VERSION_3_1_0, '<')
47-
// ) {
48-
// $property->allOf = $schemas;
49-
// } else {
50-
// $property->oneOf = $schemas;
51-
// }
52-
//
53-
// return;
54-
// }
39+
if ($types[0]->isNullable()) {
40+
$weakContext = Util::createWeakContext($property->_context);
41+
$schemas = [new OA\Schema(['ref' => $this->modelRegistry->register(new Model($type, $groups, null, $context)), '_context' => $weakContext])];
42+
$property->oneOf = $schemas;
43+
44+
return;
45+
}
5546

5647
$property->ref = $this->modelRegistry->register(new Model($type, $groups, null, $context));
5748
}

0 commit comments

Comments
 (0)