Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 5 additions & 3 deletions src/ApiDecider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Handlers/OpenApiHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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' => [],
];
Expand Down
Loading