From abcbedbd3595acc07f1a1802a5b8ac6d865a0354 Mon Sep 17 00:00:00 2001 From: MartinBeranek Date: Thu, 16 Apr 2026 10:55:01 +0200 Subject: [PATCH 1/4] Don't overwrite global preflight handler if it is set and enableGlobalPreflight is called without parameter --- CHANGELOG.md | 2 ++ src/ApiDecider.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f06437..cac331e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. ## [Unreleased][unreleased] +### Fixed +- Don't overwrite global preflight handler if it is set and enableGlobalPreflight is called without parameter ## 3.4.0 diff --git a/src/ApiDecider.php b/src/ApiDecider.php index 712eddf..ba540b7 100644 --- a/src/ApiDecider.php +++ b/src/ApiDecider.php @@ -58,7 +58,7 @@ public function getApi(string $method, string $version, string $package, ?string public function enableGlobalPreflight(?CorsPreflightHandlerInterface $corsHandler = null): void { - if (!$corsHandler) { + if (!$corsHandler && !$this->globalPreflightHandler) { $corsHandler = new CorsPreflightHandler(new Response()); } From bee268c8a5132f131cf855ab6f2c5cb404367790 Mon Sep 17 00:00:00 2001 From: MartinBeranek Date: Thu, 16 Apr 2026 10:59:54 +0200 Subject: [PATCH 2/4] pstan errors --- src/Handlers/OpenApiHandler.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Handlers/OpenApiHandler.php b/src/Handlers/OpenApiHandler.php index b72bf48..a9d5f75 100644 --- a/src/Handlers/OpenApiHandler.php +++ b/src/Handlers/OpenApiHandler.php @@ -342,6 +342,7 @@ private function getPaths(array $versionApis, string $baseUrl, string $basePath) } else { foreach ($examples as $exampleKey => $example) { $example = is_array($example) ? $example : json_decode($example, true); + /** @phpstan-ignore-next-line */ $responses[$output->getCode()]['content']['application/json; charset=utf-8']['examples'][$exampleKey] = $example; } } @@ -350,6 +351,7 @@ private function getPaths(array $versionApis, string $baseUrl, string $basePath) if (!isset($responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']['oneOf'])) { /** @phpstan-ignore-next-line */ $tmp = $responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']; + /** @phpstan-ignore-next-line */ unset($responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']); $responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema'] = [ 'oneOf' => [], From 854f0e8b81d602f04d4d2e59a74db90e33718d25 Mon Sep 17 00:00:00 2001 From: MartinBeranek Date: Thu, 16 Apr 2026 11:00:56 +0200 Subject: [PATCH 3/4] pstan errors --- src/Handlers/OpenApiHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Handlers/OpenApiHandler.php b/src/Handlers/OpenApiHandler.php index a9d5f75..5dc46ad 100644 --- a/src/Handlers/OpenApiHandler.php +++ b/src/Handlers/OpenApiHandler.php @@ -351,8 +351,8 @@ private function getPaths(array $versionApis, string $baseUrl, string $basePath) if (!isset($responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']['oneOf'])) { /** @phpstan-ignore-next-line */ $tmp = $responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']; - /** @phpstan-ignore-next-line */ unset($responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']); + /** @phpstan-ignore-next-line */ $responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema'] = [ 'oneOf' => [], ]; From 5fb32392bb2838eefd18d70fb010c609d04f8515 Mon Sep 17 00:00:00 2001 From: MartinBeranek Date: Thu, 16 Apr 2026 11:55:42 +0200 Subject: [PATCH 4/4] fix null cors handler --- src/ApiDecider.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ApiDecider.php b/src/ApiDecider.php index ba540b7..ce3f527 100644 --- a/src/ApiDecider.php +++ b/src/ApiDecider.php @@ -61,8 +61,10 @@ public function enableGlobalPreflight(?CorsPreflightHandlerInterface $corsHandle if (!$corsHandler && !$this->globalPreflightHandler) { $corsHandler = new CorsPreflightHandler(new Response()); } - - $this->globalPreflightHandler = $corsHandler; + + if ($corsHandler) { + $this->globalPreflightHandler = $corsHandler; + } } /**