feat(files): add mime icon endpoint

Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
pull/50123/head
skjnldsv 9 months ago committed by nextcloud-command
parent 7d8bb60bfe
commit 2c13259093
  1. 7
      apps/files/openapi.json
  2. 22
      core/Controller/PreviewController.php
  3. 473
      core/openapi-administration.json
  4. 41
      core/openapi-full.json
  5. 41
      core/openapi.json

@ -2330,11 +2330,16 @@
"data": {
"type": "object",
"required": [
"path"
"path",
"fileId"
],
"properties": {
"path": {
"type": "string"
},
"fileId": {
"type": "integer",
"format": "int64"
}
}
}

@ -14,6 +14,7 @@ use OCP\AppFramework\Http\Attribute\FrontpageRoute;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\OpenAPI;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Http\RedirectResponse;
@ -183,4 +184,25 @@ class PreviewController extends Controller {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}
}
/**
* Get a preview by mime
*
* @param string $mime Mime type
* @return RedirectResponse<Http::STATUS_SEE_OTHER, array{}>
*
* 303: The mime icon url
*/
#[NoCSRFRequired]
#[PublicPage]
#[FrontpageRoute(verb: 'GET', url: '/core/mimeicon')]
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT)]
public function getMimeIconUrl(string $mime = 'application/octet-stream') {
$url = $this->mimeIconProvider->getMimeIconUrl($mime);
if ($url === null) {
$url = $this->mimeIconProvider->getMimeIconUrl('application/octet-stream');
}
return new RedirectResponse($url);
}
}

@ -0,0 +1,473 @@
{
"openapi": "3.0.3",
"info": {
"title": "core-administration",
"version": "0.0.1",
"description": "Core functionality of Nextcloud",
"license": {
"name": "agpl"
}
},
"components": {
"securitySchemes": {
"basic_auth": {
"type": "http",
"scheme": "basic"
},
"bearer_auth": {
"type": "http",
"scheme": "bearer"
}
},
"schemas": {
"Capabilities": {
"type": "object",
"required": [
"core"
],
"properties": {
"core": {
"type": "object",
"required": [
"pollinterval",
"webdav-root",
"reference-api",
"reference-regex",
"mod-rewrite-working"
],
"properties": {
"pollinterval": {
"type": "integer",
"format": "int64"
},
"webdav-root": {
"type": "string"
},
"reference-api": {
"type": "boolean"
},
"reference-regex": {
"type": "string"
},
"mod-rewrite-working": {
"type": "boolean"
}
}
}
}
},
"OCSMeta": {
"type": "object",
"required": [
"status",
"statuscode"
],
"properties": {
"status": {
"type": "string"
},
"statuscode": {
"type": "integer"
},
"message": {
"type": "string"
},
"totalitems": {
"type": "string"
},
"itemsperpage": {
"type": "string"
}
}
},
"PublicCapabilities": {
"type": "object",
"required": [
"bruteforce"
],
"properties": {
"bruteforce": {
"type": "object",
"required": [
"delay",
"allow-listed"
],
"properties": {
"delay": {
"type": "integer",
"format": "int64"
},
"allow-listed": {
"type": "boolean"
}
}
}
}
}
}
},
"paths": {
"/ocs/v2.php/twofactor/state": {
"get": {
"operationId": "two_factor_api-state",
"summary": "Get two factor authentication provider states",
"description": "This endpoint requires admin access",
"tags": [
"two_factor_api"
],
"security": [
{
"bearer_auth": []
},
{
"basic_auth": []
}
],
"parameters": [
{
"name": "user",
"in": "query",
"description": "system user id",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "OCS-APIRequest",
"in": "header",
"description": "Required to be true for the API request to pass",
"required": true,
"schema": {
"type": "boolean",
"default": true
}
}
],
"responses": {
"200": {
"description": "provider states",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"type": "object",
"additionalProperties": {
"type": "boolean"
}
}
}
}
}
}
}
}
},
"404": {
"description": "user not found",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"nullable": true
}
}
}
}
}
}
}
}
}
}
},
"/ocs/v2.php/twofactor/enable": {
"post": {
"operationId": "two_factor_api-enable",
"summary": "Enable two factor authentication providers for specific user",
"description": "This endpoint requires admin access",
"tags": [
"two_factor_api"
],
"security": [
{
"bearer_auth": []
},
{
"basic_auth": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"user"
],
"properties": {
"user": {
"type": "string",
"description": "system user identifier"
},
"providers": {
"type": "array",
"default": [],
"description": "collection of TFA provider ids",
"items": {
"type": "string"
}
}
}
}
}
}
},
"parameters": [
{
"name": "OCS-APIRequest",
"in": "header",
"description": "Required to be true for the API request to pass",
"required": true,
"schema": {
"type": "boolean",
"default": true
}
}
],
"responses": {
"200": {
"description": "provider states",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"type": "object",
"additionalProperties": {
"type": "boolean"
}
}
}
}
}
}
}
}
},
"404": {
"description": "user not found",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"nullable": true
}
}
}
}
}
}
}
}
}
}
},
"/ocs/v2.php/twofactor/disable": {
"post": {
"operationId": "two_factor_api-disable",
"summary": "Disable two factor authentication providers for specific user",
"description": "This endpoint requires admin access",
"tags": [
"two_factor_api"
],
"security": [
{
"bearer_auth": []
},
{
"basic_auth": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"user"
],
"properties": {
"user": {
"type": "string",
"description": "system user identifier"
},
"providers": {
"type": "array",
"default": [],
"description": "collection of TFA provider ids",
"items": {
"type": "string"
}
}
}
}
}
}
},
"parameters": [
{
"name": "OCS-APIRequest",
"in": "header",
"description": "Required to be true for the API request to pass",
"required": true,
"schema": {
"type": "boolean",
"default": true
}
}
],
"responses": {
"200": {
"description": "provider states",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"type": "object",
"additionalProperties": {
"type": "boolean"
}
}
}
}
}
}
}
}
},
"404": {
"description": "user not found",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"ocs"
],
"properties": {
"ocs": {
"type": "object",
"required": [
"meta",
"data"
],
"properties": {
"meta": {
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"nullable": true
}
}
}
}
}
}
}
}
}
}
}
},
"tags": [
{
"name": "avatar",
"description": "Class AvatarController"
},
{
"name": "guest_avatar",
"description": "This controller handles guest avatar requests."
},
{
"name": "ocm",
"description": "Controller about the endpoint /ocm-provider/"
}
]
}

@ -8488,6 +8488,47 @@
}
}
},
"/index.php/core/mimeicon": {
"get": {
"operationId": "preview-get-mime-icon-url",
"summary": "Get a preview by mime",
"tags": [
"preview"
],
"security": [
{},
{
"bearer_auth": []
},
{
"basic_auth": []
}
],
"parameters": [
{
"name": "mime",
"in": "query",
"description": "Mime type",
"schema": {
"type": "string",
"default": "application/octet-stream"
}
}
],
"responses": {
"303": {
"description": "The mime icon url",
"headers": {
"Location": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
"/index.php/core/references/preview/{referenceId}": {
"get": {
"operationId": "reference-preview",

@ -8488,6 +8488,47 @@
}
}
},
"/index.php/core/mimeicon": {
"get": {
"operationId": "preview-get-mime-icon-url",
"summary": "Get a preview by mime",
"tags": [
"preview"
],
"security": [
{},
{
"bearer_auth": []
},
{
"basic_auth": []
}
],
"parameters": [
{
"name": "mime",
"in": "query",
"description": "Mime type",
"schema": {
"type": "string",
"default": "application/octet-stream"
}
}
],
"responses": {
"303": {
"description": "The mime icon url",
"headers": {
"Location": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
"/index.php/core/references/preview/{referenceId}": {
"get": {
"operationId": "reference-preview",

Loading…
Cancel
Save