Skip to content

Commit f605a6a

Browse files
ViPErCZsoyuka
authored andcommitted
fix(jsonschema): handle @id when genId is false
turn off inserting @id into a schema that is not a resource and has @id autogeneration turned off
1 parent a11c213 commit f605a6a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/JsonSchema/SchemaFactory.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,15 @@ private function buildPropertySchema(Schema $schema, string $definitionName, str
232232
continue;
233233
}
234234

235+
if (false === $propertyMetadata->getGenId() && !$this->isResourceClass($className)) {
236+
$subDefinitionName = $this->definitionNameFactory->create($className, $format, $className,
237+
null, $serializerContext);
238+
239+
if (isset($subSchema->getDefinitions()[$subDefinitionName])) {
240+
unset($subSchema->getDefinitions()[$subDefinitionName]['properties']['@id']);
241+
}
242+
}
243+
235244
if ($isCollection) {
236245
$propertySchema['items']['$ref'] = $subSchema['$ref'];
237246
unset($propertySchema['items']['type']);

0 commit comments

Comments
 (0)