From c341d82b412c89376b37c105e323f41dca0ed2a8 Mon Sep 17 00:00:00 2001 From: Roemer Blom Date: Sat, 28 Mar 2026 16:39:53 +0100 Subject: [PATCH 1/5] fix(openapi): default explode to true for form and cookie style parameters per OpenAPI 3.2 spec --- src/OpenApi/Model/Parameter.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/OpenApi/Model/Parameter.php b/src/OpenApi/Model/Parameter.php index 414bb356c67..ab8af9208cb 100644 --- a/src/OpenApi/Model/Parameter.php +++ b/src/OpenApi/Model/Parameter.php @@ -17,7 +17,7 @@ final class Parameter { use ExtensionTrait; - public function __construct(private string $name, private string $in, private string $description = '', private bool $required = false, private bool $deprecated = false, private ?bool $allowEmptyValue = null, private array $schema = [], private ?string $style = null, private bool $explode = false, private ?bool $allowReserved = null, private mixed $example = null, private ?\ArrayObject $examples = null, private ?\ArrayObject $content = null) + public function __construct(private string $name, private string $in, private string $description = '', private bool $required = false, private bool $deprecated = false, private ?bool $allowEmptyValue = null, private array $schema = [], private ?string $style = null, private ?bool $explode = null, private ?bool $allowReserved = null, private mixed $example = null, private ?\ArrayObject $examples = null, private ?\ArrayObject $content = null) { if (null === $style) { if ('query' === $in || 'cookie' === $in) { @@ -26,6 +26,10 @@ public function __construct(private string $name, private string $in, private st $this->style = 'simple'; } } + + if (null === $explode) { + $this->explode = \in_array($this->style, ['form', 'cookie'], true); + } } public function getName(): string From 50c34dc0f3fa78d23cb4061e38ddc1884ce5bf68 Mon Sep 17 00:00:00 2001 From: Roemer Blom Date: Sat, 28 Mar 2026 16:53:31 +0100 Subject: [PATCH 2/5] test: update explode expectations for form style parameters --- tests/Functional/Parameters/DoctrineTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Functional/Parameters/DoctrineTest.php b/tests/Functional/Parameters/DoctrineTest.php index 8fe301f5237..9631e084399 100644 --- a/tests/Functional/Parameters/DoctrineTest.php +++ b/tests/Functional/Parameters/DoctrineTest.php @@ -410,7 +410,7 @@ public static function openApiParameterDocumentationProvider(): array 'parameterName' => 'exactBrand', 'shouldHaveArrayNotation' => false, 'expectedStyle' => 'form', - 'expectedExplode' => false, + 'expectedExplode' => true, 'expectedDescription' => '', 'expectedSchema' => ['type' => 'string'], ], @@ -418,7 +418,7 @@ public static function openApiParameterDocumentationProvider(): array 'parameterName' => 'exactCategory', 'shouldHaveArrayNotation' => false, 'expectedStyle' => 'form', - 'expectedExplode' => false, + 'expectedExplode' => true, 'expectedDescription' => '', 'expectedSchema' => ['type' => 'string'], ], From eec7d4562d6b5cac89cc2d1c0ff2dc25314ff742 Mon Sep 17 00:00:00 2001 From: Roemer Blom Date: Sat, 28 Mar 2026 17:26:14 +0100 Subject: [PATCH 3/5] test: update explode expectations for form style parameters --- src/OpenApi/Tests/Factory/OpenApiFactoryTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenApi/Tests/Factory/OpenApiFactoryTest.php b/src/OpenApi/Tests/Factory/OpenApiFactoryTest.php index d8773f8c7a6..c956e108082 100644 --- a/src/OpenApi/Tests/Factory/OpenApiFactoryTest.php +++ b/src/OpenApi/Tests/Factory/OpenApiFactoryTest.php @@ -968,7 +968,7 @@ public function testInvoke(): void ], 'form', true, true, 'bar'), new Parameter('ha', 'query', '', false, false, null, [ 'type' => 'integer', - ]), + ], 'form', false), new Parameter('toto', 'query', '', true, false, null, [ 'type' => 'array', 'items' => ['type' => 'string'], @@ -976,7 +976,7 @@ public function testInvoke(): void new Parameter('order[name]', 'query', '', false, false, null, [ 'type' => 'string', 'enum' => ['asc', 'desc'], - ]), + ], 'form', false), ], ), $filteredPath->getGet()); From d4a7eb1fda47bdbe3814f3aafef594be59d31d31 Mon Sep 17 00:00:00 2001 From: Roemer Blom Date: Sat, 28 Mar 2026 17:44:35 +0100 Subject: [PATCH 4/5] test(openapi): add Parameter explode default tests --- src/OpenApi/Tests/Model/ParameterTest.php | 65 +++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/OpenApi/Tests/Model/ParameterTest.php diff --git a/src/OpenApi/Tests/Model/ParameterTest.php b/src/OpenApi/Tests/Model/ParameterTest.php new file mode 100644 index 00000000000..bdbb3d822f3 --- /dev/null +++ b/src/OpenApi/Tests/Model/ParameterTest.php @@ -0,0 +1,65 @@ +assertSame('form', $parameter->getStyle()); + $this->assertTrue($parameter->getExplode()); + } + + public function testExplodeDefaultsTrueForCookieStyle(): void + { + $parameter = new Parameter('test', 'cookie'); + $this->assertSame('form', $parameter->getStyle()); + $this->assertTrue($parameter->getExplode()); + } + + public function testExplodeDefaultsFalseForPathStyle(): void + { + $parameter = new Parameter('test', 'path'); + $this->assertSame('simple', $parameter->getStyle()); + $this->assertFalse($parameter->getExplode()); + } + + public function testExplodeDefaultsFalseForHeaderStyle(): void + { + $parameter = new Parameter('test', 'header'); + $this->assertSame('simple', $parameter->getStyle()); + $this->assertFalse($parameter->getExplode()); + } + + public function testExplicitExplodeFalseOverridesDefault(): void + { + $parameter = new Parameter('test', 'query', explode: false); + $this->assertSame('form', $parameter->getStyle()); + $this->assertFalse($parameter->getExplode()); + } + + public function testExplicitExplodeTrueOnSimpleStyle(): void + { + $parameter = new Parameter('test', 'path', explode: true); + $this->assertSame('simple', $parameter->getStyle()); + $this->assertTrue($parameter->getExplode()); + } + + public function testExplodeDefaultsTrueForExplicitFormStyle(): void + { + $parameter = new Parameter('test', 'path', style: 'form'); + $this->assertTrue($parameter->getExplode()); + } + + public function testExplodeDefaultsFalseForExplicitDeepObjectStyle(): void + { + $parameter = new Parameter('test', 'query', style: 'deepObject'); + $this->assertFalse($parameter->getExplode()); + } +} From 992a599690b9129eb5b8f8bc1ade14100c7474b4 Mon Sep 17 00:00:00 2001 From: Roemer Blom Date: Sat, 28 Mar 2026 17:48:53 +0100 Subject: [PATCH 5/5] test(openapi): added license header --- src/OpenApi/Tests/Model/ParameterTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/OpenApi/Tests/Model/ParameterTest.php b/src/OpenApi/Tests/Model/ParameterTest.php index bdbb3d822f3..e3e3218397a 100644 --- a/src/OpenApi/Tests/Model/ParameterTest.php +++ b/src/OpenApi/Tests/Model/ParameterTest.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + declare(strict_types=1); namespace ApiPlatform\OpenApi\Tests\Model;