Skip to content

Commit 68b2a62

Browse files
Merge pull request #52943 from nextcloud/feat/http/request-header-attribute
2 parents 08b9eca + ad03118 commit 68b2a62

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
'OCP\\AppFramework\\Http\\Attribute\\OpenAPI' => $baseDir . '/lib/public/AppFramework/Http/Attribute/OpenAPI.php',
8686
'OCP\\AppFramework\\Http\\Attribute\\PasswordConfirmationRequired' => $baseDir . '/lib/public/AppFramework/Http/Attribute/PasswordConfirmationRequired.php',
8787
'OCP\\AppFramework\\Http\\Attribute\\PublicPage' => $baseDir . '/lib/public/AppFramework/Http/Attribute/PublicPage.php',
88+
'OCP\\AppFramework\\Http\\Attribute\\RequestHeader' => $baseDir . '/lib/public/AppFramework/Http/Attribute/RequestHeader.php',
8889
'OCP\\AppFramework\\Http\\Attribute\\Route' => $baseDir . '/lib/public/AppFramework/Http/Attribute/Route.php',
8990
'OCP\\AppFramework\\Http\\Attribute\\StrictCookiesRequired' => $baseDir . '/lib/public/AppFramework/Http/Attribute/StrictCookiesRequired.php',
9091
'OCP\\AppFramework\\Http\\Attribute\\SubAdminRequired' => $baseDir . '/lib/public/AppFramework/Http/Attribute/SubAdminRequired.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
126126
'OCP\\AppFramework\\Http\\Attribute\\OpenAPI' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Http/Attribute/OpenAPI.php',
127127
'OCP\\AppFramework\\Http\\Attribute\\PasswordConfirmationRequired' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Http/Attribute/PasswordConfirmationRequired.php',
128128
'OCP\\AppFramework\\Http\\Attribute\\PublicPage' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Http/Attribute/PublicPage.php',
129+
'OCP\\AppFramework\\Http\\Attribute\\RequestHeader' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Http/Attribute/RequestHeader.php',
129130
'OCP\\AppFramework\\Http\\Attribute\\Route' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Http/Attribute/Route.php',
130131
'OCP\\AppFramework\\Http\\Attribute\\StrictCookiesRequired' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Http/Attribute/StrictCookiesRequired.php',
131132
'OCP\\AppFramework\\Http\\Attribute\\SubAdminRequired' => __DIR__ . '/../../..' . '/lib/public/AppFramework/Http/Attribute/SubAdminRequired.php',
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCP\AppFramework\Http\Attribute;
11+
12+
use Attribute;
13+
14+
/**
15+
* This attribute allows documenting request headers and is primarily intended for OpenAPI documentation.
16+
* It should be added whenever you use a request header in a controller method, in order to properly describe the header and its functionality.
17+
* There are no checks that ensure the header is set, so you will still need to do this yourself in the controller method.
18+
*
19+
* @since 32.0.0
20+
*/
21+
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
22+
class RequestHeader {
23+
/**
24+
* @param string $name The name of the request header
25+
* @param string $description The description of the request header
26+
*/
27+
public function __construct(
28+
protected string $name,
29+
protected string $description,
30+
) {
31+
}
32+
33+
/**
34+
* @return string The name of the request header.
35+
*
36+
* @since 32.0.0
37+
*/
38+
public function getName(): string {
39+
return $this->name;
40+
}
41+
42+
/**
43+
* @return string The description of the request header.
44+
*
45+
* @since 32.0.0
46+
*/
47+
public function getDescription(): string {
48+
return $this->description;
49+
}
50+
}

0 commit comments

Comments
 (0)