@@ -245,23 +245,20 @@ private function buildLegacyPropertySchema(Schema $schema, string $definitionNam
245245 }
246246
247247 $ subSchemaFactory = $ this ->schemaFactory ?: $ this ;
248- $ subSchema = $ subSchemaFactory ->buildSchema ($ className , $ format , $ parentType , null , $ subSchema , $ serializerContext + [self ::FORCE_SUBSCHEMA => true ], false );
248+ $ subSchema = $ subSchemaFactory ->buildSchema (
249+ $ className ,
250+ $ format ,
251+ $ parentType ,
252+ null ,
253+ $ subSchema ,
254+ $ serializerContext + [self ::FORCE_SUBSCHEMA => true , 'gen_id ' => $ propertyMetadata ->getGenId () ?? true ],
255+ false ,
256+ );
257+
249258 if (!isset ($ subSchema ['$ref ' ])) {
250259 continue ;
251260 }
252261
253- if (false === $ propertyMetadata ->getGenId ()) {
254- $ subDefinitionName = $ this ->definitionNameFactory ->create ($ className , $ format , $ className , null , $ serializerContext );
255-
256- if (isset ($ subSchema ->getDefinitions ()[$ subDefinitionName ])) {
257- // @see https://github.com/api-platform/core/issues/7162
258- // Need to rebuild the definition without @id property and set it back to the sub-schema
259- $ subSchemaDefinition = $ subSchema ->getDefinitions ()[$ subDefinitionName ]->getArrayCopy ();
260- unset($ subSchemaDefinition ['properties ' ]['@id ' ]);
261- $ subSchema ->getDefinitions ()[$ subDefinitionName ] = new \ArrayObject ($ subSchemaDefinition );
262- }
263- }
264-
265262 if ($ isCollection ) {
266263 $ key = ($ propertySchema ['type ' ] ?? null ) === 'object ' ? 'additionalProperties ' : 'items ' ;
267264 $ propertySchema [$ key ]['$ref ' ] = $ subSchema ['$ref ' ];
@@ -371,18 +368,19 @@ private function buildPropertySchema(Schema $schema, string $definitionName, str
371368 $ subSchemaInstance = new Schema ($ version );
372369 $ subSchemaInstance ->setDefinitions ($ schema ->getDefinitions ());
373370 $ subSchemaFactory = $ this ->schemaFactory ?: $ this ;
374- $ subSchemaResult = $ subSchemaFactory ->buildSchema ($ className , $ format , $ parentType , null , $ subSchemaInstance , $ serializerContext + [self ::FORCE_SUBSCHEMA => true ], false );
371+ $ subSchemaResult = $ subSchemaFactory ->buildSchema (
372+ $ className ,
373+ $ format ,
374+ $ parentType ,
375+ null ,
376+ $ subSchemaInstance ,
377+ $ serializerContext + [self ::FORCE_SUBSCHEMA => true , 'gen_id ' => $ propertyMetadata ->getGenId () ?? true ],
378+ false ,
379+ );
375380 if (!isset ($ subSchemaResult ['$ref ' ])) {
376381 continue ;
377382 }
378383
379- if (false === $ propertyMetadata ->getGenId ()) {
380- $ subDefinitionName = $ this ->definitionNameFactory ->create ($ className , $ format , $ className , null , $ serializerContext );
381- if (isset ($ subSchemaResult ->getDefinitions ()[$ subDefinitionName ]['properties ' ]['@id ' ])) {
382- unset($ subSchemaResult ->getDefinitions ()[$ subDefinitionName ]['properties ' ]['@id ' ]);
383- }
384- }
385-
386384 if ($ isCollection ) {
387385 $ key = ($ propertySchema ['type ' ] ?? null ) === 'object ' ? 'additionalProperties ' : 'items ' ;
388386 if (!isset ($ propertySchema ['type ' ])) {
0 commit comments