Skip to content

Commit 492cfc7

Browse files
committed
feat(generate-spec): Ignore index.php routes by default
Signed-off-by: provokateurin <[email protected]>
1 parent b9a7edd commit 492cfc7

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

generate-spec.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@
466466
if ($scopes === []) {
467467
if ($controllerScopes !== []) {
468468
$scopes = $controllerScopes;
469+
} elseif (!$isOCS) {
470+
$scopes = ['ignore'];
469471
} elseif ($isExApp) {
470472
$scopes = ['ex_app'];
471473
} elseif ($isAdmin) {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\Notifications\Controller;
11+
12+
use OCP\AppFramework\Controller;
13+
use OCP\AppFramework\Http;
14+
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
15+
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
16+
use OCP\AppFramework\Http\Attribute\OpenAPI;
17+
use OCP\AppFramework\Http\Response;
18+
19+
class PlainController extends Controller {
20+
#[NoCSRFRequired]
21+
#[FrontpageRoute(verb: 'GET', url: '/plain/ignored')]
22+
public function ignored(): Response {
23+
return new Response();
24+
}
25+
26+
27+
/**
28+
* Route with manual scope to not get ignored
29+
*
30+
* @return Response<Http::STATUS_OK, array{}>
31+
*
32+
* 200: Response returned
33+
*/
34+
#[NoCSRFRequired]
35+
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT)]
36+
#[FrontpageRoute(verb: 'GET', url: '/plain/with-scope')]
37+
public function withScope(): Response {
38+
return new Response();
39+
}
40+
}

tests/openapi-full.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5485,6 +5485,29 @@
54855485
}
54865486
}
54875487
},
5488+
"/index.php/apps/notifications/plain/with-scope": {
5489+
"get": {
5490+
"operationId": "plain-with-scope",
5491+
"summary": "Route with manual scope to not get ignored",
5492+
"description": "This endpoint requires admin access",
5493+
"tags": [
5494+
"plain"
5495+
],
5496+
"security": [
5497+
{
5498+
"bearer_auth": []
5499+
},
5500+
{
5501+
"basic_auth": []
5502+
}
5503+
],
5504+
"responses": {
5505+
"200": {
5506+
"description": "Response returned"
5507+
}
5508+
}
5509+
}
5510+
},
54885511
"/ocs/v2.php/apps/notifications/api/{apiVersion}/ex-app-attribute": {
54895512
"post": {
54905513
"operationId": "ex_app_settings-ex-app-scope-attribute",

tests/openapi.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,29 @@
797797
}
798798
}
799799
}
800+
},
801+
"/index.php/apps/notifications/plain/with-scope": {
802+
"get": {
803+
"operationId": "plain-with-scope",
804+
"summary": "Route with manual scope to not get ignored",
805+
"description": "This endpoint requires admin access",
806+
"tags": [
807+
"plain"
808+
],
809+
"security": [
810+
{
811+
"bearer_auth": []
812+
},
813+
{
814+
"basic_auth": []
815+
}
816+
],
817+
"responses": {
818+
"200": {
819+
"description": "Response returned"
820+
}
821+
}
822+
}
800823
}
801824
},
802825
"tags": []

0 commit comments

Comments
 (0)