Skip to content

Commit 0d78334

Browse files
Merge pull request #39257 from nextcloud/feature/openapi/comments
comments: Add OpenAPI spec
2 parents ba2e243 + 5874657 commit 0d78334

3 files changed

Lines changed: 112 additions & 4 deletions

File tree

apps/comments/lib/Capabilities.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
use OCP\Capabilities\ICapability;
2929

3030
class Capabilities implements ICapability {
31+
/**
32+
* @return array{files: array{comments: bool}}
33+
*/
3134
public function getCapabilities(): array {
3235
return [
3336
'files' => [

apps/comments/lib/Controller/NotificationsController.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
use OCP\AppFramework\Controller;
2828
use OCP\AppFramework\Http\NotFoundResponse;
2929
use OCP\AppFramework\Http\RedirectResponse;
30-
use OCP\AppFramework\Http\Response;
30+
use OCP\AppFramework\Http;
3131
use OCP\Comments\IComment;
3232
use OCP\Comments\ICommentsManager;
3333
use OCP\Files\IRootFolder;
@@ -38,8 +38,6 @@
3838
use OCP\Notification\IManager;
3939

4040
/**
41-
* Class NotificationsController
42-
*
4341
* @package OCA\Comments\Controller
4442
*/
4543
class NotificationsController extends Controller {
@@ -73,8 +71,17 @@ public function __construct(
7371
/**
7472
* @PublicPage
7573
* @NoCSRFRequired
74+
*
75+
* View a notification
76+
*
77+
* @param string $id ID of the notification
78+
*
79+
* @return RedirectResponse<Http::STATUS_SEE_OTHER, array{}>|NotFoundResponse<Http::STATUS_NOT_FOUND, array{}>
80+
*
81+
* 303: Redirected to notification
82+
* 404: Notification not found
7683
*/
77-
public function view(string $id): Response {
84+
public function view(string $id): RedirectResponse|NotFoundResponse {
7885
$currentUser = $this->userSession->getUser();
7986
if (!$currentUser instanceof IUser) {
8087
return new RedirectResponse(

apps/comments/openapi.json

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"openapi": "3.0.3",
3+
"info": {
4+
"title": "comments",
5+
"version": "0.0.1",
6+
"description": "Files app plugin to add comments to files",
7+
"license": {
8+
"name": "agpl"
9+
}
10+
},
11+
"components": {
12+
"securitySchemes": {
13+
"basic_auth": {
14+
"type": "http",
15+
"scheme": "basic"
16+
},
17+
"bearer_auth": {
18+
"type": "http",
19+
"scheme": "bearer"
20+
}
21+
},
22+
"schemas": {
23+
"Capabilities": {
24+
"type": "object",
25+
"required": [
26+
"files"
27+
],
28+
"properties": {
29+
"files": {
30+
"type": "object",
31+
"required": [
32+
"comments"
33+
],
34+
"properties": {
35+
"comments": {
36+
"type": "boolean"
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
},
44+
"paths": {
45+
"/index.php/apps/comments/notifications/view/{id}": {
46+
"get": {
47+
"operationId": "notifications-view",
48+
"summary": "View a notification",
49+
"tags": [
50+
"notifications"
51+
],
52+
"security": [
53+
{},
54+
{
55+
"bearer_auth": []
56+
},
57+
{
58+
"basic_auth": []
59+
}
60+
],
61+
"parameters": [
62+
{
63+
"name": "id",
64+
"in": "path",
65+
"description": "ID of the notification",
66+
"required": true,
67+
"schema": {
68+
"type": "string"
69+
}
70+
}
71+
],
72+
"responses": {
73+
"303": {
74+
"description": "Redirected to notification",
75+
"headers": {
76+
"Location": {
77+
"schema": {
78+
"type": "string"
79+
}
80+
}
81+
}
82+
},
83+
"404": {
84+
"description": "Notification not found",
85+
"content": {
86+
"text/html": {
87+
"schema": {
88+
"type": "string"
89+
}
90+
}
91+
}
92+
}
93+
}
94+
}
95+
}
96+
},
97+
"tags": []
98+
}

0 commit comments

Comments
 (0)