diff --git a/src/ControllerMethod.php b/src/ControllerMethod.php index 0dad47e..b23506d 100644 --- a/src/ControllerMethod.php +++ b/src/ControllerMethod.php @@ -610,10 +610,16 @@ public static function parse(string $context, $attrName = match ($key) { 0 => 'name', 1 => 'description', + 2 => 'indirect', default => throw new RuntimeException('Should not happen.'), }; } - $args[$attrName] = $arg->value->value; + + $args[$attrName] = match ($attrName) { + 'name', 'description' => $arg->value->value, + 'indirect' => $arg->value->name->name === 'true', + default => throw new RuntimeException('Should not happen.'), + }; } $headerName = self::cleanHeaderName($args['name']); @@ -628,6 +634,9 @@ public static function parse(string $context, } $attributeRequestHeaders[$headerName] = $args['description']; + if ($args['indirect'] ?? false) { + $codeRequestHeaders[] = $headerName; + } } } } diff --git a/tests/lib/Controller/SettingsController.php b/tests/lib/Controller/SettingsController.php index 6498ca0..6d58241 100644 --- a/tests/lib/Controller/SettingsController.php +++ b/tests/lib/Controller/SettingsController.php @@ -764,6 +764,7 @@ public function samePathPost(): DataResponse { #[RequestHeader('x-custom-header-2', description: 'A custom header 2')] #[RequestHeader(name: 'x-custom-header-3', description: 'A custom header 3')] #[RequestHeader(description: 'A custom header 4', name: 'x-custom-header-4')] + #[RequestHeader('x-custom-header-7', 'A custom header 7', true)] public function requestHeader(): DataResponse { $this->request->getHeader('x-custom-header-1'); $this->request->getHeader('x-custom-header-2'); diff --git a/tests/openapi-administration.json b/tests/openapi-administration.json index 24f9a83..46ba78b 100644 --- a/tests/openapi-administration.json +++ b/tests/openapi-administration.json @@ -5503,6 +5503,14 @@ "type": "string" } }, + { + "name": "x-custom-header-7", + "in": "header", + "description": "A custom header 7", + "schema": { + "type": "string" + } + }, { "name": "x-custom-header-5", "in": "header", diff --git a/tests/openapi-full.json b/tests/openapi-full.json index 4e6955f..4584809 100644 --- a/tests/openapi-full.json +++ b/tests/openapi-full.json @@ -5660,6 +5660,14 @@ "type": "string" } }, + { + "name": "x-custom-header-7", + "in": "header", + "description": "A custom header 7", + "schema": { + "type": "string" + } + }, { "name": "x-custom-header-5", "in": "header",