fix(doctrine): honor castToArray and schema in filter OpenAPI parameters#8423
Open
soyuka wants to merge 1 commit into
Open
fix(doctrine): honor castToArray and schema in filter OpenAPI parameters#8423soyuka wants to merge 1 commit into
soyuka wants to merge 1 commit into
Conversation
OpenApiFilterTrait::getOpenApiParameters() returned a singular parameter whenever a scalar schema was set, overriding castToArray, and built the singular parameter without its declared schema. castToArray is now the sole control — false: singular, true: array, null: both — and the declared schema is passed through in every case. Fixes api-platform#8406
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.
What
OpenApiFilterTrait::getOpenApiParameters()(used byExactFilter,PartialSearchFilter,IriFilter,SortFilter,OrFilter) had two problems:schemawas set, ignoringcastToArray— socastToArray: trueproduced a singular parameter, and the default (null→ both singular + array) was never reached for scalar-typed parameters.OpenApiParameterwas built without its declaredschema, so an explicitschema: ['type' => 'integer']was dropped.castToArrayis now the sole control, and the schema is always passed through:castToArray === false→ singular onlycastToArray === true→ array onlycastToArray === null(default) → bothtype: array, else['type' => 'array', 'items' => <schema>].Behavior change
A scalar-typed parameter with default
castToArraynow exposes bothkeyandkey[](previously singular-only when a scalar schema was set). This matches the oldSearchFilterbehavior and the documented default. Consequence: abooleanExactFilterwithschema: ['type' => 'boolean']and nocastToArraynow also emitskey[]; setcastToArray: falsefor a single parameter (the docs are being updated accordingly).Test
ExactFilterSchemaParameterTestasserts the OpenAPI output for the four cases from the issue (scalar + default → both;castToArray: true→ array only;castToArray: false→ singular only; explicit array schema +castToArray: true→ single array, no duplicate). Fails on 2/4 before the fix, all green after. Fulltests/Functional/Parameters/+OpenApiTestsuites green; php-cs-fixer clean; PHPStan[OK].