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

Added self link to StorageFile API representation

Andreas Pfohl2554e265c44a
diff --git a/docs/api/apiv3/components/schemas/file_collection_model.yml b/docs/api/apiv3/components/schemas/file_collection_model.yml
index 934a01fe35b..acde99e41f2 100644
--- a/docs/api/apiv3/components/schemas/file_collection_model.yml
+++ b/docs/api/apiv3/components/schemas/file_collection_model.yml
@@ -47,6 +47,9 @@ example:
lastModifiedAt: '2021-12-20T14:00:13.987Z'
createdByName: Luke Skywalker
lastModifiedByName: Anakin Skywalker
+ _links:
+ self:
+ href: 'urn:openproject-org:api:v3:storages:storage_file:no_link_provided'
- id: 1338
location: '1338'
name: README.md
@@ -56,3 +59,6 @@ example:
lastModifiedAt: '2021-12-21T14:00:13.987Z'
createdByName: Leia Organa
lastModifiedByName: Leia Organa
+ _links:
+ self:
+ href: 'urn:openproject-org:api:v3:storages:storage_file:no_link_provided'
diff --git a/docs/api/apiv3/components/schemas/storage_file_location_model.yml b/docs/api/apiv3/components/schemas/storage_file_location_model.yml
index 3bfe1122a45..367afb2cad1 100644
--- a/docs/api/apiv3/components/schemas/storage_file_location_model.yml
+++ b/docs/api/apiv3/components/schemas/storage_file_location_model.yml
@@ -7,3 +7,16 @@ properties:
location:
type: string
description: Location identification for file in storage
+ _links:
+ type: object
+ required:
+ - self
+ properties:
+ self:
+ allOf:
+ - "$ref": "./link.yml"
+ - description: |-
+ Not provided
+
+ **Resource**: urn:openproject-org:api:v3:storages:storage_file:no_link_provided
+ readOnly: true
diff --git a/modules/storages/lib/api/v3/storage_files/storage_file_representer.rb b/modules/storages/lib/api/v3/storage_files/storage_file_representer.rb
index dde6f36c54d..adbb49e5bf3 100644
--- a/modules/storages/lib/api/v3/storage_files/storage_file_representer.rb
+++ b/modules/storages/lib/api/v3/storage_files/storage_file_representer.rb
@@ -30,6 +30,10 @@ module API::V3::StorageFiles
class StorageFileRepresenter < ::API::Decorators::Single
include API::Decorators::DateProperty
+ link :self do
+ { href: "#{::API::V3::URN_PREFIX}storages:storage_file:no_link_provided" }
+ end
+
property :id
property :name
property :size
@@ -41,7 +45,7 @@ module API::V3::StorageFiles
property :location
def _type
- 'StorageFile'
+ Storages::StorageFile.class.to_s
end
end
end