Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#43694] added endpoint spec for storage files

Eric Schubert9f42ddfd5e3b
diff --git a/docs/api/apiv3/components/schemas/file_collection_model.yml b/docs/api/apiv3/components/schemas/file_collection_model.yml
new file mode 100644
index 00000000000..4f34338c48b
--- /dev/null
+++ b/docs/api/apiv3/components/schemas/file_collection_model.yml
@@ -0,0 +1,56 @@
+# Schema: FileCollectionModel
+---
+allOf:
+ - $ref: './collection_model.yml'
+ - type: object
+ required:
+ - _links
+ - _embedded
+ properties:
+ _links:
+ type: object
+ required:
+ - self
+ properties:
+ self:
+ allOf:
+ - $ref: "./link.yml"
+ - description: |-
+ This file links collection
+
+ **Resource**: FileLinkCollectionReadModel
+ _embedded:
+ type: object
+ required:
+ - elements
+ properties:
+ elements:
+ type: array
+ items:
+ $ref: './file_link_origin_data_model.yml'
+
+example:
+ _type: Collection
+ total: 2
+ count: 2
+ _links:
+ self:
+ href: '/api/v3/storages/42/files'
+ _embedded:
+ elements:
+ - id: 1337
+ name: logo.png
+ mimeType: image/png
+ size: 16042
+ createdAt: '2021-12-19T09:42:10.170Z'
+ lastModifiedAt: '2021-12-20T14:00:13.987Z'
+ createdByName: Luke Skywalker
+ lastModifiedByName: Anakin Skywalker
+ - id: 1338
+ name: README.md
+ mimeType: text/markdown
+ size: 3742
+ createdAt: '2021-12-20T09:42:10.170Z'
+ lastModifiedAt: '2021-12-21T14:00:13.987Z'
+ createdByName: Leia Organa
+ lastModifiedByName: Leia Organa
diff --git a/docs/api/apiv3/openapi-spec.yml b/docs/api/apiv3/openapi-spec.yml
index 2fe3de57b45..e965f46d215 100644
--- a/docs/api/apiv3/openapi-spec.yml
+++ b/docs/api/apiv3/openapi-spec.yml
@@ -353,6 +353,8 @@ paths:
"$ref": "./paths/status.yml"
"/api/v3/storages/{id}":
"$ref": "./paths/storage.yml"
+ "/api/v3/storages/{id}/files":
+ "$ref": "./paths/storage_files.yml"
"/api/v3/time_entries":
"$ref": "./paths/time_entries.yml"
"/api/v3/time_entries/{id}/form":
@@ -552,6 +554,8 @@ components:
"$ref": "./components/schemas/example_schema_model.yml"
Execute_custom_action:
"$ref": "./components/schemas/execute_custom_action.yml"
+ FileCollectionModel:
+ $ref: './components/schemas/file_collection_model.yml'
FileLinkCollectionReadModel:
$ref: './components/schemas/file_link_collection_read_model.yml'
FileLinkCollectionWriteModel:
diff --git a/docs/api/apiv3/paths/storage.yml b/docs/api/apiv3/paths/storage.yml
index d5f1f3734b6..7b73abb5080 100644
--- a/docs/api/apiv3/paths/storage.yml
+++ b/docs/api/apiv3/paths/storage.yml
@@ -1,8 +1,8 @@
# /api/v3/storages/{id}
---
get:
- summary: Gets a file link.
- operationId: Get_Storage
+ summary: Gets a storage.
+ operationId: get_storage
tags:
- File links
description: |-
diff --git a/docs/api/apiv3/paths/storage_files.yml b/docs/api/apiv3/paths/storage_files.yml
new file mode 100644
index 00000000000..dfdec78fde5
--- /dev/null
+++ b/docs/api/apiv3/paths/storage_files.yml
@@ -0,0 +1,48 @@
+# /api/v3/storages/{id}/files
+---
+get:
+ summary: Gets files of a storage.
+ operationId: get_storage_files
+ tags:
+ - File links
+ description: |-
+ Gets a collection of file data from a storage. When giving no `root` context, the result is the content of the
+ document root. With `root` context given, the result contains the collections of file data from without the given
+ root file id.
+ parameters:
+ - name: id
+ description: Storage id
+ in: path
+ required: true
+ schema:
+ type: integer
+ example: 1337
+ - name: root
+ description: Root file id
+ in: query
+ required: false
+ schema:
+ type: integer
+ example: 53
+ responses:
+ '200':
+ description: OK
+ content:
+ application/hal+json:
+ schema:
+ $ref: '../components/schemas/file_collection_model.yml'
+ '404':
+ content:
+ application/hal+json:
+ schema:
+ $ref: "../components/schemas/error_response.yml"
+ example:
+ _type: Error
+ errorIdentifier: urn:openproject-org:api:v3:errors:NotFound
+ message: The requested resource could not be found.
+ description: |-
+ Returned in either of those cases:
+ - if the storage does not exist or the client does not have sufficient permissions to see it
+
+ **Required permission:** view file links
+ - if the document root file id do not exist on the storage