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

[chore] split read and write models

Eric Schubert9b46ac563ea9
diff --git a/docs/api/apiv3/components/schemas/file_links_model.yml b/docs/api/apiv3/components/schemas/file_link_collection_read_model.yml
similarity index 91%
rename from docs/api/apiv3/components/schemas/file_links_model.yml
rename to docs/api/apiv3/components/schemas/file_link_collection_read_model.yml
index 401e79aefd2..e9b0cb55a30 100644
--- a/docs/api/apiv3/components/schemas/file_links_model.yml
+++ b/docs/api/apiv3/components/schemas/file_link_collection_read_model.yml
@@ -1,7 +1,7 @@
-# Schema: File_LinksModel
+# Schema: FileLinkCollectionReadModel
---
allOf:
- - "$ref": './collection_model.yml'
+ - $ref: './collection_model.yml'
- type: object
required:
- _links
@@ -14,12 +14,11 @@ allOf:
properties:
self:
allOf:
- - "$ref": "./link.yml"
+ - $ref: "./link.yml"
- description: |-
This file links list
**Resource**: File_LinksModel
- readOnly: true
_embedded:
type: object
required:
@@ -28,7 +27,7 @@ allOf:
elements:
type: array
items:
- $ref: './file_link_model.yml'
+ $ref: './file_link_read_model.yml'
example:
_type: Collection
@@ -47,6 +46,7 @@ example:
id: 5503
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
diff --git a/docs/api/apiv3/components/schemas/file_link_collection_write_model.yml b/docs/api/apiv3/components/schemas/file_link_collection_write_model.yml
new file mode 100644
index 00000000000..a0a47eb27a2
--- /dev/null
+++ b/docs/api/apiv3/components/schemas/file_link_collection_write_model.yml
@@ -0,0 +1,35 @@
+# Schema: FileLinkCollectionWriteModel
+---
+allOf:
+ - $ref: './collection_model.yml'
+ - type: object
+ required:
+ - _embedded
+ properties:
+ _embedded:
+ type: object
+ required:
+ - elements
+ properties:
+ elements:
+ type: array
+ items:
+ $ref: './file_link_write_model.yml'
+
+example:
+ _embedded:
+ elements:
+ - originData:
+ id: 5503
+ 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
+ _links:
+ storage:
+ href: /api/v3/storage/42
+ - _hint: File Link resource shortened for brevity
+ id: 1338
diff --git a/docs/api/apiv3/components/schemas/file_link_origin_data_model.yml b/docs/api/apiv3/components/schemas/file_link_origin_data_model.yml
index 6354f17faf3..68007054e04 100644
--- a/docs/api/apiv3/components/schemas/file_link_origin_data_model.yml
+++ b/docs/api/apiv3/components/schemas/file_link_origin_data_model.yml
@@ -1,10 +1,11 @@
-# Schema: File_Link_Origin_DataModel
+# Schema: FileLinkOriginDataModel
---
type: object
required:
- id
- name
- mimeType
+ - size
- createdAt
- lastModifiedAt
- createdByName
@@ -20,12 +21,16 @@ properties:
type: string
minLength: 0
description: MIME type of the linked file
+ size:
+ type: integer
+ minimum: 0
+ description: file size on origin in bytes
createdAt:
type: string
format: date-time
description: Timestamp of the creation datetime of the file on the origin
lastModifiedAt:
- type: string
+ type: stringa
format: date-time
description: Timestamp of the datetime of the last modification of the file on the origin
createdByName:
diff --git a/docs/api/apiv3/components/schemas/file_link_model.yml b/docs/api/apiv3/components/schemas/file_link_read_model.yml
similarity index 89%
rename from docs/api/apiv3/components/schemas/file_link_model.yml
rename to docs/api/apiv3/components/schemas/file_link_read_model.yml
index 50003f2afb9..26e804aa502 100644
--- a/docs/api/apiv3/components/schemas/file_link_model.yml
+++ b/docs/api/apiv3/components/schemas/file_link_read_model.yml
@@ -1,4 +1,4 @@
-# Schema: File_LinkModel
+# Schema: FileLinkReadModel
---
type: object
required:
@@ -10,27 +10,22 @@ properties:
id:
type: integer
description: File link id
- readOnly: true
_type:
type: string
enum:
- FileLink
- readOnly: true
createdAt:
type: string
format: date-time
description: Time of creation
- readOnly: true
updatedAt:
type: string
format: date-time
description: Time of the most recent change to the file link
- readOnly: true
originData:
$ref: './file_link_origin_data_model.yml'
_embedded:
type: object
- readOnly: true
required:
- storage
- container
@@ -56,7 +51,6 @@ properties:
This file link.
**Resource**: FileLink
- readOnly: true
storage:
allOf:
- $ref: './link.yml'
@@ -64,14 +58,6 @@ properties:
The storage resource of the linked file.
**Resource**: Storage
- storageUrl:
- allOf:
- - $ref: './link.yml'
- - description: |-
- The storage url the file link references to.
-
- **Resource**: N/A
- writeOnly: true
container:
allOf:
- $ref: './link.yml'
@@ -81,7 +67,6 @@ properties:
Can be one of the following **Resources**:
- WorkPackage
- readOnly: true
creator:
allOf:
- $ref: './link.yml'
@@ -89,7 +74,6 @@ properties:
The creator of the file link.
**Resource**: User
- readOnly: true
delete:
allOf:
- $ref: './link.yml'
@@ -97,7 +81,6 @@ properties:
The uri to delete the file link.
**Resource**: N/A
- readOnly: true
originOpen:
allOf:
- $ref: './link.yml'
@@ -105,7 +88,6 @@ properties:
The uri to open the origin file on the origin itself.
**Resource**: N/A
- readOnly: true
staticOriginOpen:
allOf:
- $ref: './link.yml'
@@ -113,7 +95,6 @@ properties:
A static uri to open the origin file on the storage. Responds with a redirect.
**Resource**: N/A
- readOnly: true
example:
id: 1337
@@ -124,6 +105,7 @@ example:
id: 5503
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
diff --git a/docs/api/apiv3/components/schemas/file_link_write_model.yml b/docs/api/apiv3/components/schemas/file_link_write_model.yml
new file mode 100644
index 00000000000..f596d148604
--- /dev/null
+++ b/docs/api/apiv3/components/schemas/file_link_write_model.yml
@@ -0,0 +1,47 @@
+# Schema: FileLinkWriteModel
+---
+type: object
+required:
+ - originData
+ - _links
+properties:
+ originData:
+ $ref: './file_link_origin_data_model.yml'
+ _links:
+ oneOf:
+ - type: object
+ required:
+ - storage
+ properties:
+ storage:
+ allOf:
+ - $ref: './link.yml'
+ - description: |-
+ The storage resource of the linked file.
+
+ **Resource**: Storage
+ - type: object
+ required:
+ - storageUrl
+ properties:
+ storageUrl:
+ allOf:
+ - $ref: './link.yml'
+ - description: |-
+ The storage url the file link references to.
+
+ **Resource**: N/A
+
+example:
+ originData:
+ id: 5503
+ 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
+ _links:
+ storageUrl:
+ href: 'https://nextcloud.my-deathstar.org'
diff --git a/docs/api/apiv3/openapi-spec.yml b/docs/api/apiv3/openapi-spec.yml
index 4c79b933724..4bae7131081 100644
--- a/docs/api/apiv3/openapi-spec.yml
+++ b/docs/api/apiv3/openapi-spec.yml
@@ -521,12 +521,16 @@ components:
"$ref": "./components/schemas/example_schema_model.yml"
Execute_custom_action:
"$ref": "./components/schemas/execute_custom_action.yml"
- File_LinkModel:
- "$ref": "./components/schemas/file_link_model.yml"
- File_Link_Origin_DataModel:
+ FileLinkCollectionReadModel:
+ $ref: './components/schemas/file_link_collection_read_model.yml'
+ FileLinkCollectionWriteModel:
+ $ref: './components/schemas/file_link_collection_write_model.yml'
+ FileLinkOriginDataModel:
"$ref": "./components/schemas/file_link_origin_data_model.yml"
- File_LinksModel:
- "$ref": "./components/schemas/file_links_model.yml"
+ FileLinkReadModel:
+ $ref: './components/schemas/file_link_read_model.yml'
+ FileLinkWriteModel:
+ $ref: './components/schemas/file_link_write_model.yml'
FormModel:
"$ref": "./components/schemas/form_model.yml"
Formattable:
diff --git a/docs/api/apiv3/paths/file_link.yml b/docs/api/apiv3/paths/file_link.yml
index 28f920b6b2e..261fa14a082 100644
--- a/docs/api/apiv3/paths/file_link.yml
+++ b/docs/api/apiv3/paths/file_link.yml
@@ -22,7 +22,7 @@ get:
content:
application/hal+json:
schema:
- $ref: '../components/schemas/file_link_model.yml'
+ $ref: '../components/schemas/file_link_read_model.yml'
'404':
content:
application/hal+json:
diff --git a/docs/api/apiv3/paths/work_package_file_links.yml b/docs/api/apiv3/paths/work_package_file_links.yml
index 3665252d102..6027b61cc85 100644
--- a/docs/api/apiv3/paths/work_package_file_links.yml
+++ b/docs/api/apiv3/paths/work_package_file_links.yml
@@ -28,7 +28,7 @@ post:
content:
application/json:
schema:
- $ref: '../components/schemas/file_links_model.yml'
+ $ref: '../components/schemas/file_link_collection_write_model.yml'
example:
_type: Collection
_embedded:
@@ -51,7 +51,7 @@ post:
content:
application/hal+json:
schema:
- $ref: '../components/schemas/file_links_model.yml'
+ $ref: '../components/schemas/file_link_collection_read_model.yml'
'400':
content:
application/hal+json:
@@ -125,7 +125,7 @@ get:
content:
application/hal+json:
schema:
- $ref: '../components/schemas/file_links_model.yml'
+ $ref: '../components/schemas/file_link_collection_read_model.yml'
'403':
content:
application/hal+json: