From 5321ffa0193e284ad241a4c5729354ddc574695c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Debrauwer?= Date: Thu, 26 Jun 2025 17:02:23 +0200 Subject: [PATCH 1/2] Add failing test --- tests/Fixtures/CommaSeparatedString.v1.json | 11 +++++++++++ tests/RequestValidatorTest.php | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/Fixtures/CommaSeparatedString.v1.json b/tests/Fixtures/CommaSeparatedString.v1.json index e63d676..1ed6a21 100644 --- a/tests/Fixtures/CommaSeparatedString.v1.json +++ b/tests/Fixtures/CommaSeparatedString.v1.json @@ -115,6 +115,17 @@ "enum": ["foo", "bar"] } } + }, + { + "name": "X-Include", + "in": "header", + "schema": { + "type": "array", + "items": { + "type": "string", + "enum": ["foo", "bar"] + } + } } ] } diff --git a/tests/RequestValidatorTest.php b/tests/RequestValidatorTest.php index c088ebe..8e493c8 100644 --- a/tests/RequestValidatorTest.php +++ b/tests/RequestValidatorTest.php @@ -791,7 +791,9 @@ public function test_comma_separated_values() }) ->middleware(Middleware::class); - $this->getJson('/users?include=foo,bar') + $this + ->withHeader('X-Include', 'foo,bar') + ->getJson('/users?include=foo,bar') ->assertStatus(200) ->assertValidRequest() ->assertValidResponse(); From 8f2e01890671afa44f15496a18f0bce8ef732b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Debrauwer?= Date: Thu, 26 Jun 2025 17:02:43 +0200 Subject: [PATCH 2/2] Update request validator --- src/Validation/RequestValidator.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Validation/RequestValidator.php b/src/Validation/RequestValidator.php index d09fcf6..95e60ac 100644 --- a/src/Validation/RequestValidator.php +++ b/src/Validation/RequestValidator.php @@ -102,6 +102,10 @@ protected function validateParameters(): void } } elseif ($parameter->in === 'header' && $this->request->headers->has($parameter->name)) { $parameterValue = $this->request->headers->get($parameter->name); + + if ($parameter->explode === false && $parameter->schema->type === 'array') { + $parameterValue = explode(',', $parameterValue); + } } elseif ($parameter->in === 'cookie' && $this->request->cookies->has($parameter->name)) { $parameterValue = $this->request->cookies->get($parameter->name); }