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..ce3f527 100644 --- a/src/ApiDecider.php +++ b/src/ApiDecider.php @@ -58,11 +58,13 @@ 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()); } - - $this->globalPreflightHandler = $corsHandler; + + if ($corsHandler) { + $this->globalPreflightHandler = $corsHandler; + } } /** diff --git a/src/Handlers/OpenApiHandler.php b/src/Handlers/OpenApiHandler.php index b72bf48..5dc46ad 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; } } @@ -351,6 +352,7 @@ private function getPaths(array $versionApis, string $baseUrl, string $basePath) /** @phpstan-ignore-next-line */ $tmp = $responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']; 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' => [], ];