Add global defaults.normalization_context.gen_id configuration option#7775
Open
olinox14 wants to merge 4 commits intoapi-platform:mainfrom
Open
Add global defaults.normalization_context.gen_id configuration option#7775olinox14 wants to merge 4 commits intoapi-platform:mainfrom
olinox14 wants to merge 4 commits intoapi-platform:mainfrom
Conversation
Member
|
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.
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 |
added 2 commits
February 18, 2026 17:10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add the possibility to set a new option in api/config/packages/api_platform.yaml (or config/api-platform.php for Laravel) :
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.