-
-
Notifications
You must be signed in to change notification settings - Fork 928
Open
Description
API Platform version(s) affected: 4.1.21
Description
With this parameters configuration, if API endpoint is called with '/api/my_resources?booleanParameter=false'
, parameter value is true
. Expected is to be false
#[ApiResource(
operations: [
new GetCollection(
parameters: [
'booleanParameter' => new QueryParameter(
schema: [
'type' => 'boolean',
'default' => true, <---------- Override value when value is false
],
castToNativeType: true,
),
],
),
]
)]
How to reproduce
Simple reproducer: https://github.com/alamirault/api-platform-query-parameter-default
Possible Solution
ParameterProvider
should maybe updated to not override sent values
core/src/State/Provider/ParameterProvider.php
Lines 84 to 86 in 9e382e0
if (($default = $parameter->getSchema()['default'] ?? false) && ($value instanceof ParameterNotFound || !$value)) { | |
$value = $default; | |
} |
Additional Context
Metadata
Metadata
Assignees
Labels
No labels