fix(openapi): document array query parameters with bracket notation - #8600
Merged
Merged
Conversation
soyuka
force-pushed
the
fix/issue-8421
branch
from
September 28, 2026 14:11
f6e0328 to
cb38c5a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An array-typed
QueryParameterwith 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 passedstyle/explode, soOpenApi\Model\Parameterdefaulted them toform/trueforin: query. That serializes as repeated bare keys (ids=1&ids=2), butRequestParser::parseRequestParams()is built onparse_str, where only theids[]=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()emitskey[]and honours the existing tri-statecastToArray. This applies the same rule to the filterless path, so no new option is introduced.Only the OpenAPI parameter name gains the
[]suffix. TheQueryParameter's key is untouched, becauseextractParameterValues()looks values up by$parameter->getKey()whileRequestParserhex-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: queryand its declared schema is alreadytype: array:type: array: bare name only, always, whatevercastToArraysays.castToArray: false: bare name only.castToArray: true:key[]only.castToArrayunset: 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. SettingcastToArrayexplicitly narrows it to one.getFilterParameter()and the filter-backed branch are untouched.