Skip to content

fix(openapi): document array query parameters with bracket notation - #8600

Merged
soyuka merged 1 commit into
api-platform:4.4from
soyuka:fix/issue-8421
Sep 28, 2026
Merged

soyuka merged 1 commit into
api-platform:4.4from
soyuka:fix/issue-8421

Conversation

@soyuka

@soyuka soyuka commented Sep 28, 2026

Copy link
Copy Markdown
Member
Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fixes #8421
License MIT

An array-typed QueryParameter with no filter attached was documented in a form API Platform cannot parse back.

The filterless branch of OpenApiFactory::collectPaths() never inspected the schema and never passed style/explode, so OpenApi\Model\Parameter defaulted them to form/true for in: query. That serializes as repeated bare keys (ids=1&ids=2), but RequestParser::parseRequestParams() is built on parse_str, where only the ids[]= bracket form yields an array. A client following the document sent the documented URL and the server kept only the last value.

The filter-backed path already solves this: Doctrine\Common\Filter\OpenApiFilterTrait::getOpenApiParameters() emits key[] and honours the existing tri-state castToArray. This applies the same rule to the filterless path, so no new option is introduced.

Only the OpenAPI parameter name gains the [] suffix. The QueryParameter's key is untouched, because extractParameterValues() looks values up by $parameter->getKey() while RequestParser hex-encodes only the segment before [, yielding the bare key.

Two gates keep this off every existing API. The array variant is emitted only when the parameter is in: query and its declared schema is already type: array:

  • schema is not type: array: bare name only, always, whatever castToArray says.
  • castToArray: false: bare name only.
  • castToArray: true: key[] only.
  • castToArray unset: both forms.

Header parameters are excluded: there is no bracket-array wire format for headers.

Both gates are pinned by tests, including a scalar-schema query parameter and an array-schema header parameter, each asserted to emit exactly one unchanged parameter.

One reviewer note: when the user supplies their own openapi: parameter and both forms are emitted, their customization is merged into each. Setting castToArray explicitly narrows it to one.

getFilterParameter() and the filter-backed branch are untouched.

@soyuka
soyuka merged commit eca4fb1 into api-platform:4.4 Sep 28, 2026
112 of 117 checks passed
@soyuka
soyuka deleted the fix/issue-8421 branch September 28, 2026 15:40
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.

1 participant