Skip to content

Commit

Permalink
Add single status code descriptions for OpenAPI
Browse files Browse the repository at this point in the history
Signed-off-by: jld3103 <jld3103yt@gmail.com>
  • Loading branch information
provokateurin committed Sep 19, 2023
1 parent e0c778f commit d70602e
Show file tree
Hide file tree
Showing 44 changed files with 228 additions and 130 deletions.
6 changes: 6 additions & 0 deletions apps/dashboard/lib/Controller/DashboardApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ static function (IWidget $widget) use ($widgetIds) {
* @param int $limit Limit number of result items per widget
* @param string[] $widgets Limit results to specific widgets
* @return DataResponse<Http::STATUS_OK, array<string, DashboardWidgetItem[]>, array{}>
*
* 200: Widget items returned
*/
public function getWidgetItems(array $sinceIds = [], int $limit = 7, array $widgets = []): DataResponse {
$items = [];
Expand All @@ -129,6 +131,8 @@ public function getWidgetItems(array $sinceIds = [], int $limit = 7, array $widg
* @param int $limit Limit number of result items per widget
* @param string[] $widgets Limit results to specific widgets
* @return DataResponse<Http::STATUS_OK, array<string, DashboardWidgetItems>, array{}>
*
* 200: Widget items returned
*/
public function getWidgetItemsV2(array $sinceIds = [], int $limit = 7, array $widgets = []): DataResponse {
$items = [];
Expand All @@ -151,6 +155,8 @@ public function getWidgetItemsV2(array $sinceIds = [], int $limit = 7, array $wi
* @NoCSRFRequired
*
* @return DataResponse<Http::STATUS_OK, DashboardWidget[], array{}>
*
* 200: Widgets returned
*/
public function getWidgets(): DataResponse {
$widgets = $this->dashboardManager->getWidgets();
Expand Down
6 changes: 3 additions & 3 deletions apps/dashboard/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
],
"responses": {
"200": {
"description": "",
"description": "Widgets returned",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -293,7 +293,7 @@
],
"responses": {
"200": {
"description": "",
"description": "Widget items returned",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -389,7 +389,7 @@
],
"responses": {
"200": {
"description": "",
"description": "Widget items returned",
"content": {
"application/json": {
"schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public function __construct(string $appName,
* @param string|null $ownerFederatedId Federated ID of the receiver
* @return Http\DataResponse<Http::STATUS_OK, array<empty>, array{}>
* @throws OCSException
*
* 200: Share created successfully
*/
public function createShare(
?string $remote = null,
Expand Down Expand Up @@ -284,6 +286,8 @@ public function acceptShare(int $id, ?string $token = null) {
* @param string|null $token Shared secret between servers
* @return Http\DataResponse<Http::STATUS_OK, array<empty>, array{}>
* @throws OCSException
*
* 200: Share declined successfully
*/
public function declineShare(int $id, ?string $token = null) {
$notification = [
Expand Down Expand Up @@ -316,6 +320,8 @@ public function declineShare(int $id, ?string $token = null) {
* @param string|null $token Shared secret between servers
* @return Http\DataResponse<Http::STATUS_OK, array<empty>, array{}>
* @throws OCSException
*
* 200: Share unshared successfully
*/
public function unshare(int $id, ?string $token = null) {
if (!$this->isS2SEnabled()) {
Expand Down
6 changes: 3 additions & 3 deletions apps/federatedfilesharing/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
],
"responses": {
"200": {
"description": "",
"description": "Share created successfully",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -629,7 +629,7 @@
],
"responses": {
"200": {
"description": "",
"description": "Share declined successfully",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -707,7 +707,7 @@
],
"responses": {
"200": {
"description": "",
"description": "Share unshared successfully",
"content": {
"application/json": {
"schema": {
Expand Down
8 changes: 2 additions & 6 deletions apps/files/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use OCA\Files\Service\ViewConfig;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\IgnoreOpenAPI;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
Expand Down Expand Up @@ -389,13 +390,8 @@ public function getGridView() {
* @NoAdminRequired
* @NoCSRFRequired
* @PublicPage
*
* Get the service-worker Javascript for previews
*
* @psalm-suppress MoreSpecificReturnType The value of Service-Worker-Allowed is not relevant
* @psalm-suppress LessSpecificReturnStatement The value of Service-Worker-Allowed is not relevant
* @return StreamResponse<Http::STATUS_OK, array{Content-Type: 'application/javascript', Service-Worker-Allowed: string}>
*/
#[IgnoreOpenAPI]
public function serviceWorker(): StreamResponse {
$response = new StreamResponse(__DIR__ . '/../../../../dist/preview-service-worker.js');
$response->setHeaders([
Expand Down
2 changes: 2 additions & 0 deletions apps/files/lib/Controller/DirectEditingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public function __construct(
*
* Get the direct editing capabilities
* @return DataResponse<Http::STATUS_OK, array{editors: array<string, array{id: string, name: string, mimetypes: string[], optionalMimetypes: string[], secure: bool}>, creators: array<string, array{id: string, editor: string, name: string, extension: string, templates: bool, mimetypes: string[]}>}, array{}>
*
* 200: Direct editing capabilities returned
*/
public function info(): DataResponse {
$response = new DataResponse($this->directEditingService->getDirectEditingCapabilitites());
Expand Down
2 changes: 2 additions & 0 deletions apps/files/lib/Controller/TemplateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public function __construct($appName, IRequest $request, ITemplateManager $templ
* List the available templates
*
* @return DataResponse<Http::STATUS_OK, array<FilesTemplateFileCreator>, array{}>
*
* 200: Available templates returned
*/
public function list(): DataResponse {
return new DataResponse($this->templateManager->listTemplates());
Expand Down
42 changes: 2 additions & 40 deletions apps/files/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,44 +332,6 @@
}
}
},
"/index.php/apps/files/preview-service-worker.js": {
"get": {
"operationId": "api-service-worker",
"summary": "Get the service-worker Javascript for previews",
"tags": [
"api"
],
"security": [
{},
{
"bearer_auth": []
},
{
"basic_auth": []
}
],
"responses": {
"200": {
"description": "",
"headers": {
"Service-Worker-Allowed": {
"schema": {
"type": "string"
}
}
},
"content": {
"application/javascript": {
"schema": {
"type": "string",
"format": "binary"
}
}
}
}
}
}
},
"/ocs/v2.php/apps/files/api/v1/directEditing": {
"get": {
"operationId": "direct_editing-info",
Expand Down Expand Up @@ -398,7 +360,7 @@
],
"responses": {
"200": {
"description": "",
"description": "Direct editing capabilities returned",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -1041,7 +1003,7 @@
],
"responses": {
"200": {
"description": "",
"description": "Available templates returned",
"content": {
"application/json": {
"schema": {
Expand Down
2 changes: 2 additions & 0 deletions apps/files_external/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ private function formatMount(string $mountPoint, StorageConfig $mountConfig): ar
* Get the mount points visible for this user
*
* @return DataResponse<Http::STATUS_OK, FilesExternalMount[], array{}>
*
* 200: User mounts returned
*/
public function getUserMounts(): DataResponse {
$entries = [];
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
],
"responses": {
"200": {
"description": "",
"description": "User mounts returned",
"content": {
"application/json": {
"schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ private function formatShare(IShare $share): array {
* Get a list of all deleted shares
*
* @return DataResponse<Http::STATUS_OK, FilesSharingDeletedShare[], array{}>
*
* 200: Deleted shares returned
*/
public function index(): DataResponse {
$groupShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_GROUP, null, -1, 0);
Expand Down
4 changes: 4 additions & 0 deletions apps/files_sharing/lib/Controller/RemoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public function __construct(
* Get list of pending remote shares
*
* @return DataResponse<Http::STATUS_OK, FilesSharingRemoteShare[], array{}>
*
* 200: Pending remote shares returned
*/
public function getOpenShares() {
return new DataResponse($this->externalManager->getOpenShares());
Expand Down Expand Up @@ -138,6 +140,8 @@ private static function extendShareInfo($share) {
* Get a list of accepted remote shares
*
* @return DataResponse<Http::STATUS_OK, FilesSharingRemoteShare[], array{}>
*
* 200: Accepted remote shares returned
*/
public function getShares() {
$shares = $this->externalManager->getAcceptedShares();
Expand Down
2 changes: 2 additions & 0 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,8 @@ public function updateShare(
* Get all shares that are still pending
*
* @return DataResponse<Http::STATUS_OK, FilesSharingShare[], array{}>
*
* 200: Pending shares returned
*/
public function pendingShares(): DataResponse {
$pendingShares = [];
Expand Down
2 changes: 2 additions & 0 deletions apps/files_sharing/lib/Controller/ShareesAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ private function getAllSharees(string $user, array $shareTypes): ISearchResult {
* @param string $itemType Limit to specific item types
* @param int|int[]|null $shareType Limit to specific share types
* @return DataResponse<Http::STATUS_OK, FilesSharingShareesRecommendedResult, array{}>
*
* 200: Recommended sharees returned
*/
public function findRecommended(string $itemType, $shareType = null): DataResponse {
$shareTypes = [
Expand Down
10 changes: 5 additions & 5 deletions apps/files_sharing/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2107,7 +2107,7 @@
],
"responses": {
"200": {
"description": "",
"description": "Pending shares returned",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -2609,7 +2609,7 @@
],
"responses": {
"200": {
"description": "",
"description": "Deleted shares returned",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -2900,7 +2900,7 @@
],
"responses": {
"200": {
"description": "",
"description": "Recommended sharees returned",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -2960,7 +2960,7 @@
],
"responses": {
"200": {
"description": "",
"description": "Accepted remote shares returned",
"content": {
"application/json": {
"schema": {
Expand Down Expand Up @@ -3023,7 +3023,7 @@
],
"responses": {
"200": {
"description": "",
"description": "Pending remote shares returned",
"content": {
"application/json": {
"schema": {
Expand Down
2 changes: 2 additions & 0 deletions apps/provisioning_api/lib/Controller/AppConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public function __construct(string $appName,
* Get a list of apps
*
* @return DataResponse<Http::STATUS_OK, array{data: string[]}, array{}>
*
* 200: Apps returned
*/
public function getApps(): DataResponse {
return new DataResponse([
Expand Down
8 changes: 8 additions & 0 deletions apps/provisioning_api/lib/Controller/AppsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public function __construct(
* @param ?string $filter Filter for enabled or disabled apps
* @return DataResponse<Http::STATUS_OK, array{apps: string[]}, array{}>
* @throws OCSException
*
* 200: Installed apps returned
*/
public function getApps(?string $filter = null): DataResponse {
$apps = (new OC_App())->listAllApps();
Expand Down Expand Up @@ -94,6 +96,8 @@ public function getApps(?string $filter = null): DataResponse {
* @param string $app ID of the app
* @return DataResponse<Http::STATUS_OK, ProvisioningApiAppInfo, array{}>
* @throws OCSException
*
* 200: App info returned
*/
public function getAppInfo(string $app): DataResponse {
$info = $this->appManager->getAppInfo($app);
Expand All @@ -112,6 +116,8 @@ public function getAppInfo(string $app): DataResponse {
* @param string $app ID of the app
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
* @throws OCSException
*
* 200: App enabled successfully
*/
public function enable(string $app): DataResponse {
try {
Expand All @@ -129,6 +135,8 @@ public function enable(string $app): DataResponse {
*
* @param string $app ID of the app
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
*
* 200: App disabled successfully
*/
public function disable(string $app): DataResponse {
$this->appManager->disableApp($app);
Expand Down
Loading

0 comments on commit d70602e

Please sign in to comment.