API Platform version(s) affected: 4.2
In the same context than #7656 and #7634, I encounter some issue with the default implementation from OpenApiFilterTrait::getOpenApiParameters @soyuka @vinceAmstoutz about the schema.
I dunno if it's a bug or something I wrongly understand since I found test about it in ApiPlatform code base.
Description
For a "basic" filter
'brand' => new QueryParameter(filter: new ExactFilter()),
ApiPlatform seems to expect
{
"name": "brand[]",
"in": "query",
"description": "",
"required": false,
"deprecated": false,
"schema": {
"type": "string"
},
"style": "deepObject",
"explode": true
},
according to
|
'default behavior (no castToArray, no schema) should use array notation' => [ |
|
'parameterName' => 'brand', |
|
'shouldHaveArrayNotation' => true, |
|
'expectedStyle' => 'deepObject', |
|
'expectedExplode' => true, |
|
'expectedSchemaType' => 'string', |
|
], |
But since it's an array notation brand[], I would have expect a default schema of something like
"schema": { "type": "array", "items": "string" },
because the brand filter can be used in the following way /foo?brand[]=brand1&brand[]=brand2 and because of the name brand[] (and not brand)
Do I misunderstand when an array schema or is there some confusion in ApiPlatform code about [] suffix in the filter name vs the schema... ?
Additional Context
The "default" schema of string is coming from these lines
|
$defaultSchema = ['type' => 'string']; |
|
if (null !== $p->getDefault()) { |
|
$defaultSchema['default'] = $p->getDefault(); |
|
} |
|
|
|
$defaultParameter = new Parameter( |
|
$key, |
|
$in, |
|
$p->getDescription() ?? "$resourceShortName $key", |
|
$p->getRequired() ?? false, |
|
false, |
|
null, |
|
$p->getSchema() ?? $defaultSchema, |
|
); |
and here, the
[] name is generated, without adding any schema
|
return new OpenApiParameter(name: $parameter->getKey().'[]', in: 'query', style: 'deepObject', explode: true); |
API Platform version(s) affected: 4.2
In the same context than #7656 and #7634, I encounter some issue with the default implementation from OpenApiFilterTrait::getOpenApiParameters @soyuka @vinceAmstoutz about the schema.
I dunno if it's a bug or something I wrongly understand since I found test about it in ApiPlatform code base.
Description
For a "basic" filter
ApiPlatform seems to expect
according to
core/tests/Functional/Parameters/DoctrineTest.php
Lines 349 to 355 in bd3ed98
But since it's an array notation
brand[], I would have expect a default schema of something likebecause the brand filter can be used in the following way
/foo?brand[]=brand1&brand[]=brand2and because of the namebrand[](and notbrand)Do I misunderstand when an array schema or is there some confusion in ApiPlatform code about
[]suffix in the filter name vs the schema... ?Additional Context
The "default" schema of string is coming from these lines
core/src/OpenApi/Factory/OpenApiFactory.php
Lines 340 to 353 in bd3ed98
and here, the
[]name is generated, without adding any schemacore/src/Doctrine/Common/Filter/OpenApiFilterTrait.php
Line 39 in bd3ed98