Skip to content

Comments

fix(hydra): hide search key when there is parameter without filter#7773

Merged
soyuka merged 2 commits intoapi-platform:4.2from
VincentLanglet:fix/search
Feb 17, 2026
Merged

fix(hydra): hide search key when there is parameter without filter#7773
soyuka merged 2 commits intoapi-platform:4.2from
VincentLanglet:fix/search

Conversation

@VincentLanglet
Copy link
Contributor

Q A
Branch? 4.2
Tickets Closes #..., closes #...
License MIT
Doc PR api-platform/docs#...

When a custom query parameter is added in the parameter list like

parameters: [
                'withPages' => new QueryParameter(schema: ['type' => 'boolean'], description: 'Include related pages in the response', hydra: false),
            ],

for instance in order to add dynamically normalizationContext group, ApiPlatform is generating

+    'search' => Array &7 [
+        '@type' => 'IriTemplate',
+        'template' => '/foo/id/bar{?}',
+        'variableRepresentation' => 'BasicRepresentation',
+        'mapping' => Array &8 [],
+    ],

which is pretty useless since there is no key with the {?}.

@VincentLanglet
Copy link
Contributor Author

Seems like you added a test #7293 which check the opposite of what I'm trying to do in this PR @soyuka.

To me there is no need to add

['hydra:search' => [
            'hydra:template' => '/with_parameters_filter_without_property.jsonld{?}',
            'hydra:mapping' => [
            ],
        ]

if there is no parameter nor mapping to describe in the search. Do you see it differently ?

@soyuka
Copy link
Member

soyuka commented Feb 17, 2026

indeed I don't think its mandatory okay to change my test!

@VincentLanglet VincentLanglet marked this pull request as ready for review February 17, 2026 13:06
@VincentLanglet
Copy link
Contributor Author

indeed I don't think its mandatory okay to change my test!

Done, is 4.2 the right target or the next release will be 4.3 ?

@soyuka soyuka merged commit 75ffdc4 into api-platform:4.2 Feb 17, 2026
129 of 130 checks passed
@soyuka
Copy link
Member

soyuka commented Feb 17, 2026

perfect thanks! 4.3 will be out in 2-3 weeks for now we stick with 4.2

@VincentLanglet
Copy link
Contributor Author

perfect thanks! 4.3 will be out in 2-3 weeks for now we stick with 4.2

Thanks.

The same parameter also generates me

    'view' => Array &3 [
        '@id' => '/foo/id/bar?withPages=1',
         '@type' => 'PartialCollectionView',
     ],

in the response when used. Even if it's not a real "PartialCollectionView".

I also discovered that calling any url with a non-existing query param like /foo/id/bar?hello=42 does generates

    'view' => Array &3 [
        '@id' => '/foo/id/bar?hello=42',
         '@type' => 'PartialCollectionView',
     ],

Is it expected ? Is PartialCollectionView the right keyword ?

@soyuka
Copy link
Member

soyuka commented Feb 17, 2026

Yes this is correct

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