fix(openapi): correct parameter name when QueryParameter remaps a filter property#8377
Closed
rodnaph wants to merge 1 commit into
Closed
fix(openapi): correct parameter name when QueryParameter remaps a filter property#8377rodnaph wants to merge 1 commit into
rodnaph wants to merge 1 commit into
Conversation
…ter property When a QueryParameter uses `property` to remap a filter's property name (e.g. `order[sort_by]` mapped to property `rating`), OpenApiFactory used `str_replace(, , )` to rewrite the filter description key. Because both the description key (`order[rating]`) and the replacement key (`order[sort_by]`) share the `order[...]` wrapper, the naive str_replace produced `order[order[sort_by]]`. Fix: skip filter description entries that don't match the mapped property and use the QueryParameter key directly as the parameter name.
soyuka
reviewed
Jul 2, 2026
| use Doctrine\ORM\Mapping as ORM; | ||
|
|
||
| #[ORM\Entity] | ||
| #[ApiFilter(OrderFilter::class, alias: 'product_order_filter', properties: ['rating'])] |
Member
There was a problem hiding this comment.
ApiFilter will get deprecated/removed, did you try specifying the filter inside the QueryParameter instead?
Author
There was a problem hiding this comment.
Ah that's simpler, thanks!
Apologies for the distraction.
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.
When a QueryParameter uses
propertyto remap a filter's property name (e.g.order[sort_by]mapped to propertyrating), OpenApiFactory usedstr_replace(, , )to rewrite the filter description key. Because both the description key (order[rating]) and the replacement key (order[sort_by]) share theorder[...]wrapper, the naive str_replace producedorder[order[sort_by]].The fix is to skip filter description entries that don't match the mapped property and use the QueryParameter key directly as the parameter name.
Workaround
Register two
#[ApiFilter]attributes per resource:The QueryParameter sets
openApi: falseandhydra: falseto suppress the auto-generated entries.