From 7197eaaa27dd57286ba53ed13cc92f69de78cef5 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Wed, 6 Nov 2024 09:40:12 +0100 Subject: [PATCH 1/2] fix: allow empty header name --- src/PHPDraft/Out/OpenAPI/OpenApiRenderer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PHPDraft/Out/OpenAPI/OpenApiRenderer.php b/src/PHPDraft/Out/OpenAPI/OpenApiRenderer.php index fe728f0..8e89fad 100644 --- a/src/PHPDraft/Out/OpenAPI/OpenApiRenderer.php +++ b/src/PHPDraft/Out/OpenAPI/OpenApiRenderer.php @@ -164,7 +164,7 @@ private function toOperation(HTTPRequest $request, Transition $transition, array foreach ($request->headers as $name => $value) { if ($name === 'Content-Type') { continue; } - if ($name === $this->base_data['API_KEY_HEADER']) { + if ($name === $this->base_data['API_KEY_HEADER'] ?? NULL) { $operation['security'] = [["api_key" => []]]; continue; } @@ -511,4 +511,4 @@ private function getTags(): array { return $return; } -} \ No newline at end of file +} From c978b9e4454846a05dcd476c76705f52aa903423 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Wed, 6 Nov 2024 09:46:53 +0100 Subject: [PATCH 2/2] fix: phpstan issue --- src/PHPDraft/Out/OpenAPI/OpenApiRenderer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PHPDraft/Out/OpenAPI/OpenApiRenderer.php b/src/PHPDraft/Out/OpenAPI/OpenApiRenderer.php index 8e89fad..a95b9dc 100644 --- a/src/PHPDraft/Out/OpenAPI/OpenApiRenderer.php +++ b/src/PHPDraft/Out/OpenAPI/OpenApiRenderer.php @@ -164,7 +164,8 @@ private function toOperation(HTTPRequest $request, Transition $transition, array foreach ($request->headers as $name => $value) { if ($name === 'Content-Type') { continue; } - if ($name === $this->base_data['API_KEY_HEADER'] ?? NULL) { + if (isset($this->base_data['API_KEY_HEADER']) + && $this->base_data['API_KEY_HEADER'] === $name) { $operation['security'] = [["api_key" => []]]; continue; }