diff --git a/src/PSR7/Validators/SerializedParameter.php b/src/PSR7/Validators/SerializedParameter.php index 9405ce8c..1fe17fb2 100644 --- a/src/PSR7/Validators/SerializedParameter.php +++ b/src/PSR7/Validators/SerializedParameter.php @@ -166,11 +166,11 @@ private function castToSchemaType($value, ?string $type) */ protected function convertToSerializationStyle($value, ?CebeSchema $schema) { - if ( - $this->explode === false - && in_array($this->style, [self::STYLE_FORM, self::STYLE_SPACE_DELIMITED, self::STYLE_PIPE_DELIMITED], true) - ) { - $value = explode(self::STYLE_DELIMITER_MAP[$this->style], $value); + if (in_array($this->style, [self::STYLE_FORM, self::STYLE_SPACE_DELIMITED, self::STYLE_PIPE_DELIMITED], true)) { + if ($this->explode === false) { + $value = explode(self::STYLE_DELIMITER_MAP[$this->style], $value); + } + foreach ($value as &$val) { $val = $this->castToSchemaType($val, $schema->items->type ?? null); } diff --git a/tests/FromCommunity/Issue140Test.php b/tests/FromCommunity/Issue140Test.php new file mode 100644 index 00000000..9f3e58cf --- /dev/null +++ b/tests/FromCommunity/Issue140Test.php @@ -0,0 +1,68 @@ +fromJson($json)->getServerRequestValidator(); + + $queryString = 'id[]=1&id[]=2'; + $query = null; + parse_str($queryString, $query); + + $psrRequest = (new ServerRequest('get', 'http://localhost:8000/api/list')) + ->withHeader('Content-Type', 'application/json') + ->withQueryParams($query); + + $validator->validate($psrRequest); + + $this->addToAssertionCount(1); + } +}