diff --git a/core/configuration.md b/core/configuration.md index a7be08eb722..1fa5f69b03d 100644 --- a/core/configuration.md +++ b/core/configuration.md @@ -324,6 +324,10 @@ api_platform: normalization_context: # Default value to omit null values in conformance with the JSON Merge Patch RFC. skip_null_values: true + + # Set to false to disable the generation of Skolem IRIs (`/.well-known/genid/{id}`) globally. + # Available since API Platform 4.3, see the serialization documentation. + gen_id: true denormalization_context: ~ swagger_context: ~ openapi_context: ~ @@ -756,6 +760,10 @@ return [ 'normalization_context' => [ // Default value to omit null values in conformance with the JSON Merge Patch RFC. 'skip_null_values' => true, + + // Set to false to disable the generation of Skolem IRIs (`/.well-known/genid/{id}`) globally. + // Available since API Platform 4.3, see the serialization documentation. + 'gen_id' => true, ], 'denormalization_context' => null, diff --git a/core/serialization.md b/core/serialization.md index 22479d29861..7548c7f4a9a 100644 --- a/core/serialization.md +++ b/core/serialization.md @@ -799,6 +799,57 @@ class PlainIdentifierDenormalizer implements DenormalizerInterface, Denormalizer } ``` +## Disabling Skolem IRIs for Embedded Objects + +When a relation is embedded and the related object has no identifier, API Platform generates a +Skolem IRI (`/.well-known/genid/{id}`) as the `@id` of the embedded object. To omit it, set the +`genId` option of `#[ApiProperty]` to `false` on the property: + +```php + [ + 'normalization_context' => [ + 'gen_id' => false, + ], + ], +]; +``` + +The `genId` option of `#[ApiProperty]` takes precedence over the global default, so +`#[ApiProperty(genId: true)]` keeps generating the Skolem IRI of a given property. + ## Property Normalization Context for Symfony If you want to change the (de)normalization context of a property, for instance if you want to