Skip to content

Add global defaults.normalization_context.gen_id configuration option#7775

Open
olinox14 wants to merge 4 commits intoapi-platform:mainfrom
olinox14:feature/global-genid-setting
Open

Add global defaults.normalization_context.gen_id configuration option#7775
olinox14 wants to merge 4 commits intoapi-platform:mainfrom
olinox14:feature/global-genid-setting

Conversation

@olinox14
Copy link

@olinox14 olinox14 commented Feb 17, 2026

Q A
Branch? main
Tickets None
License MIT
Doc PR api-platform/docs#2252

Add the possibility to set a new option in api/config/packages/api_platform.yaml (or config/api-platform.php for Laravel) :

api_platform:
    defaults:
        normalization_context:
            gen_id: false

If set to false, this will globally disable the Skolem IRIs generation for all properties.
If not set, the default value for $context['output']['gen_id'] would stay true.
#[ApiProperty(genId: true|false)] will still take precedence.

@soyuka
Copy link
Member

soyuka commented Feb 17, 2026

Hi thanks for the feature! Could you add a test (functional or unit your choice)?

I wonder if it would be nice to have actual property defaults.

Allows configuring the `genId` option globally via `defaults.normalization_context`.

Adds new functional tests to verify that `genId` works as expected when configured globally,
and that the `genId` option on `ApiProperty` takes precedence over the global option.
@olinox14
Copy link
Author

I added the tests, please note that I only tested it for the use case that pushed me to propose this PR, i.e. a DTO ApiResource with embedded sub-resources (which are not defined as ApiResources). I'm not sure if there are cases where this feature could be needed with the child resources also defined as ApiResources?

Property defaults defined in the configuration file would be even more elegant imo, but I don’t know the project enough to realize the feasibility

Olivier Massot added 2 commits February 18, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments