@@ -245,23 +245,20 @@ private function buildLegacyPropertySchema(Schema $schema, string $definitionNam
245
245
}
246
246
247
247
$ 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
+
249
258
if (!isset ($ subSchema ['$ref ' ])) {
250
259
continue ;
251
260
}
252
261
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
-
265
262
if ($ isCollection ) {
266
263
$ key = ($ propertySchema ['type ' ] ?? null ) === 'object ' ? 'additionalProperties ' : 'items ' ;
267
264
$ propertySchema [$ key ]['$ref ' ] = $ subSchema ['$ref ' ];
@@ -371,18 +368,19 @@ private function buildPropertySchema(Schema $schema, string $definitionName, str
371
368
$ subSchemaInstance = new Schema ($ version );
372
369
$ subSchemaInstance ->setDefinitions ($ schema ->getDefinitions ());
373
370
$ 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
+ );
375
380
if (!isset ($ subSchemaResult ['$ref ' ])) {
376
381
continue ;
377
382
}
378
383
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
-
386
384
if ($ isCollection ) {
387
385
$ key = ($ propertySchema ['type ' ] ?? null ) === 'object ' ? 'additionalProperties ' : 'items ' ;
388
386
if (!isset ($ propertySchema ['type ' ])) {
0 commit comments