Skip to content

Commit ab326c8

Browse files
fix(JsonSchema): Rebuild sub-schema definition without @id property when genId is false (#7162)
1 parent 85e18a2 commit ab326c8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/JsonSchema/SchemaFactory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,11 @@ private function buildPropertySchema(Schema $schema, string $definitionName, str
226226
$subDefinitionName = $this->definitionNameFactory->create($className, $format, $className, null, $serializerContext);
227227

228228
if (isset($subSchema->getDefinitions()[$subDefinitionName])) {
229-
unset($subSchema->getDefinitions()[$subDefinitionName]['properties']['@id']);
229+
// @see https://github.com/api-platform/core/issues/7162
230+
// Need to rebuild the definition without @id property and set it back to the sub-schema
231+
$subSchemaDefinition = $subSchema->getDefinitions()[$subDefinitionName]->getArrayCopy();
232+
unset($subSchemaDefinition['properties']['@id']);
233+
$subSchema->getDefinitions()[$subDefinitionName] = new \ArrayObject($subSchemaDefinition);
230234
}
231235
}
232236

0 commit comments

Comments
 (0)