mirror of
https://github.com/nextcloud/server.git
synced 2026-06-14 19:20:35 -04:00
Merge pull request #40421 from nextcloud/fix/openapi/core/reference-api
core: Fix OpenAPI for reference API
This commit is contained in:
commit
b2e10841b5
6 changed files with 71 additions and 73 deletions
|
|
@ -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())) {
|
||||
|
|
|
|||
|
|
@ -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 = [];
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,4 +126,11 @@ interface IReference extends JsonSerializable {
|
|||
* @since 25.0.0
|
||||
*/
|
||||
public function getOpenGraphObject(): array;
|
||||
|
||||
/**
|
||||
* @return array{richObjectType: string, richObject: array<string, mixed>, openGraphObject: array{id: string, name: string, description: ?string, thumb: ?string, link: string}, accessible: bool}
|
||||
*
|
||||
* @since 25.0.0
|
||||
*/
|
||||
public function jsonSerialize(): array;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ class Reference implements IReference {
|
|||
* @since 25.0.0
|
||||
* @return array{richObjectType: string, richObject: array<string, mixed>, openGraphObject: OpenGraphObject, accessible: bool}
|
||||
*/
|
||||
public function jsonSerialize() {
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'richObjectType' => $this->getRichObjectType(),
|
||||
'richObject' => $this->getRichObject(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue