Skip to content

Commit

Permalink
Merge pull request #39257 from nextcloud/feature/openapi/comments
Browse files Browse the repository at this point in the history
comments: Add OpenAPI spec
  • Loading branch information
provokateurin authored Jul 10, 2023
2 parents ba2e243 + 5874657 commit 0d78334
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 4 deletions.
3 changes: 3 additions & 0 deletions apps/comments/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
use OCP\Capabilities\ICapability;

class Capabilities implements ICapability {
/**
* @return array{files: array{comments: bool}}
*/
public function getCapabilities(): array {
return [
'files' => [
Expand Down
15 changes: 11 additions & 4 deletions apps/comments/lib/Controller/NotificationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
use OCP\Files\IRootFolder;
Expand All @@ -38,8 +38,6 @@
use OCP\Notification\IManager;

/**
* Class NotificationsController
*
* @package OCA\Comments\Controller
*/
class NotificationsController extends Controller {
Expand Down Expand Up @@ -73,8 +71,17 @@ public function __construct(
/**
* @PublicPage
* @NoCSRFRequired
*
* View a notification
*
* @param string $id ID of the notification
*
* @return RedirectResponse<Http::STATUS_SEE_OTHER, array{}>|NotFoundResponse<Http::STATUS_NOT_FOUND, array{}>
*
* 303: Redirected to notification
* 404: Notification not found
*/
public function view(string $id): Response {
public function view(string $id): RedirectResponse|NotFoundResponse {
$currentUser = $this->userSession->getUser();
if (!$currentUser instanceof IUser) {
return new RedirectResponse(
Expand Down
98 changes: 98 additions & 0 deletions apps/comments/openapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"openapi": "3.0.3",
"info": {
"title": "comments",
"version": "0.0.1",
"description": "Files app plugin to add comments to files",
"license": {
"name": "agpl"
}
},
"components": {
"securitySchemes": {
"basic_auth": {
"type": "http",
"scheme": "basic"
},
"bearer_auth": {
"type": "http",
"scheme": "bearer"
}
},
"schemas": {
"Capabilities": {
"type": "object",
"required": [
"files"
],
"properties": {
"files": {
"type": "object",
"required": [
"comments"
],
"properties": {
"comments": {
"type": "boolean"
}
}
}
}
}
}
},
"paths": {
"/index.php/apps/comments/notifications/view/{id}": {
"get": {
"operationId": "notifications-view",
"summary": "View a notification",
"tags": [
"notifications"
],
"security": [
{},
{
"bearer_auth": []
},
{
"basic_auth": []
}
],
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of the notification",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"303": {
"description": "Redirected to notification",
"headers": {
"Location": {
"schema": {
"type": "string"
}
}
}
},
"404": {
"description": "Notification not found",
"content": {
"text/html": {
"schema": {
"type": "string"
}
}
}
}
}
}
}
},
"tags": []
}

0 comments on commit 0d78334

Please sign in to comment.