diff options
author | jld3103 <jld3103yt@gmail.com> | 2023-09-14 12:26:14 +0200 |
---|---|---|
committer | jld3103 <jld3103yt@gmail.com> | 2023-09-14 15:49:13 +0200 |
commit | 79b8b5c0f20ffee738b57f3b2b5779a8002a9c23 (patch) | |
tree | c5eac6222105aadaed1120a2db846b4a74829556 /core | |
parent | 30a7eabad3f00fe10fa2d66725297a559aa82c3c (diff) | |
download | nextcloud-server-79b8b5c0f20ffee738b57f3b2b5779a8002a9c23.tar.gz nextcloud-server-79b8b5c0f20ffee738b57f3b2b5779a8002a9c23.zip |
core: Fix OpenAPI for reference API
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/Controller/CollaborationResourcesController.php | 6 | ||||
-rw-r--r-- | core/Controller/ReferenceApiController.php | 4 | ||||
-rw-r--r-- | core/ResponseDefinitions.php | 18 | ||||
-rw-r--r-- | core/openapi.json | 107 |
4 files changed, 63 insertions, 72 deletions
diff --git a/core/Controller/CollaborationResourcesController.php b/core/Controller/CollaborationResourcesController.php index 832b4207e6f..e1389309c15 100644 --- a/core/Controller/CollaborationResourcesController.php +++ b/core/Controller/CollaborationResourcesController.php @@ -44,7 +44,7 @@ use OCP\IUserSession; use Psr\Log\LoggerInterface; /** - * @psalm-import-type CoreOpenGraphObject from ResponseDefinitions + * @psalm-import-type CoreResource from ResponseDefinitions * @psalm-import-type CoreCollection from ResponseDefinitions */ class CollaborationResourcesController extends OCSController { @@ -313,7 +313,7 @@ class CollaborationResourcesController extends OCSController { } /** - * @return CoreOpenGraphObject[] + * @return CoreResource[] */ protected function prepareResources(array $resources): array { $result = []; @@ -331,7 +331,7 @@ class CollaborationResourcesController extends OCSController { } /** - * @return CoreOpenGraphObject + * @return CoreResource */ protected function prepareResource(IResource $resource): array { if (!$resource->canAccess($this->userSession->getUser())) { diff --git a/core/Controller/ReferenceApiController.php b/core/Controller/ReferenceApiController.php index c16ca348d88..3d144c8559f 100644 --- a/core/Controller/ReferenceApiController.php +++ b/core/Controller/ReferenceApiController.php @@ -55,7 +55,7 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { * @param string $text Text to extract from * @param bool $resolve Resolve the references * @param int $limit Maximum amount of references to extract - * @return DataResponse<Http::STATUS_OK, array{references: array<string, CoreReference|mixed|null>}, array{}> + * @return DataResponse<Http::STATUS_OK, array{references: array<string, CoreReference|null>}, array{}> */ public function extract(string $text, bool $resolve = false, int $limit = 1): DataResponse { $references = $this->referenceManager->extractReferences($text); @@ -99,7 +99,7 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { * * @param string[] $references References to resolve * @param int $limit Maximum amount of references to resolve - * @return DataResponse<Http::STATUS_OK, array{references: array<string, CoreReference|mixed|null>}, array{}> + * @return DataResponse<Http::STATUS_OK, array{references: array<string, CoreReference|null>}, array{}> */ public function resolve(array $references, int $limit = 1): DataResponse { $result = []; diff --git a/core/ResponseDefinitions.php b/core/ResponseDefinitions.php index 3820e71645d..1e5d97b6267 100644 --- a/core/ResponseDefinitions.php +++ b/core/ResponseDefinitions.php @@ -61,22 +61,24 @@ namespace OCA\Core; * } * * @psalm-type CoreOpenGraphObject = array{ + * id: string, + * name: string, + * description: ?string, + * thumb: ?string, + * link: string, + * } + * + * @psalm-type CoreResource = array{ * richObjectType: string, * richObject: array<string, mixed>, - * openGraphObject: array{ - * id: string, - * name: string, - * description: ?string, - * thumb: ?string, - * link: string, - * }, + * openGraphObject: CoreOpenGraphObject, * accessible: bool, * } * * @psalm-type CoreCollection = array{ * id: int, * name: string, - * resources: CoreOpenGraphObject[], + * resources: CoreResource[], * } * * @psalm-type CoreReference = array{ diff --git a/core/openapi.json b/core/openapi.json index 1cc8b40483f..c586ed73ad0 100644 --- a/core/openapi.json +++ b/core/openapi.json @@ -73,7 +73,7 @@ "resources": { "type": "array", "items": { - "$ref": "#/components/schemas/OpenGraphObject" + "$ref": "#/components/schemas/Resource" } } } @@ -226,52 +226,29 @@ "OpenGraphObject": { "type": "object", "required": [ - "richObjectType", - "richObject", - "openGraphObject", - "accessible" + "id", + "name", + "description", + "thumb", + "link" ], "properties": { - "richObjectType": { + "id": { "type": "string" }, - "richObject": { - "type": "object", - "additionalProperties": { - "type": "object" - } + "name": { + "type": "string" }, - "openGraphObject": { - "type": "object", - "required": [ - "id", - "name", - "description", - "thumb", - "link" - ], - "properties": { - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "description": { - "type": "string", - "nullable": true - }, - "thumb": { - "type": "string", - "nullable": true - }, - "link": { - "type": "string" - } - } + "description": { + "type": "string", + "nullable": true }, - "accessible": { - "type": "boolean" + "thumb": { + "type": "string", + "nullable": true + }, + "link": { + "type": "string" } } }, @@ -333,6 +310,32 @@ } } }, + "Resource": { + "type": "object", + "required": [ + "richObjectType", + "richObject", + "openGraphObject", + "accessible" + ], + "properties": { + "richObjectType": { + "type": "string" + }, + "richObject": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "openGraphObject": { + "$ref": "#/components/schemas/OpenGraphObject" + }, + "accessible": { + "type": "boolean" + } + } + }, "Status": { "type": "object", "required": [ @@ -3334,15 +3337,8 @@ "references": { "type": "object", "additionalProperties": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/Reference" - }, - { - "type": "object" - } - ] + "$ref": "#/components/schemas/Reference", + "nullable": true } } } @@ -3441,15 +3437,8 @@ "references": { "type": "object", "additionalProperties": { - "nullable": true, - "oneOf": [ - { - "$ref": "#/components/schemas/Reference" - }, - { - "type": "object" - } - ] + "$ref": "#/components/schemas/Reference", + "nullable": true } } } |