-
-
Notifications
You must be signed in to change notification settings - Fork 888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GetCollection ignores ApiFilter required properties #6734
Comments
Hi, have you checked the documentation? You can declare parameters on a Resource or an Operation through the parameters property. In your example:
A
|
Your suggestion is almost perfect. If i do any changes on the filter (e.g. property is no longer required) I would need to apply this change on all resources where my filter is used. Current solution is, to set alias to the filter and use it parameters list. Downside of this solution is that I need to set on all resources a parameters and link them with my filter. #[ApiResource(
operations: [
new GetCollection(
provider: Provider::class,
parameters: [
'prop' => new QueryParameter(filter: 'MyFilterClass')
]
),
],
paginationEnabled: false,
)]
#[ApiFilter(
filterClass: Filter::class,
properties: [
'prop' => 'filter_a',
],
alias: 'MyFilterClass',
)] |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
API Platform version(s) affected: 4.0.3, 4.0.4 (Symfony)
Description
API Filters required parameters seems to be lost with the upgrade from v3.2.26 to 4.0.4 (Symfony). In previous version http reponse code was 400 with a description that query parameter is required. In 4.0.4 response is 200 with the data.
OpenAPI specification (api/docs) shows the query parameter field as required in both versions.
How to reproduce
Have a resource with getCollection (with custom data provider) and ApiFilter which defines one property as required.
Expected behavior is to get the http reponse 400 with an description that property is required instead of http 200. (Response examples are below)
Additional Context
Resource example:
Collection provider example:
Filter:
Response from 3.2.26:
Response from 4.0.4:
The text was updated successfully, but these errors were encountered: