Skip to content

Commit 85e6209

Browse files
committed
1 parent f01c762 commit 85e6209

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/JsonSchema/SchemaFactory.php

+15-12
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,23 @@ private function buildPropertySchema(Schema $schema, string $definitionName, str
217217
}
218218

219219
$subSchema = $this->buildSchema($className, $format, $parentType, null, $subSchema, $serializerContext + [self::FORCE_SUBSCHEMA => true], false);
220-
if ($isCollection) {
221-
$propertySchema['items']['$ref'] = $subSchema['$ref'];
222-
unset($propertySchema['items']['type']);
223-
break;
224-
}
225220

226-
if ($type->isNullable()) {
227-
$propertySchema['anyOf'] = [['$ref' => $subSchema['$ref']], ['type' => 'null']];
228-
} else {
229-
$propertySchema['$ref'] = $subSchema['$ref'];
230-
}
221+
if (isset($subSchema['$ref'])) {
222+
if ($isCollection) {
223+
$propertySchema['items']['$ref'] = $subSchema['$ref'];
224+
unset($propertySchema['items']['type']);
225+
break;
226+
}
231227

232-
unset($propertySchema['type']);
233-
break;
228+
if ($type->isNullable()) {
229+
$propertySchema['anyOf'] = [['$ref' => $subSchema['$ref']], ['type' => 'null']];
230+
} else {
231+
$propertySchema['$ref'] = $subSchema['$ref'];
232+
}
233+
234+
unset($propertySchema['type']);
235+
break;
236+
}
234237
}
235238

236239
$schema->getDefinitions()[$definitionName]['properties'][$normalizedPropertyName] = new \ArrayObject($propertySchema);

0 commit comments

Comments
 (0)