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

Add swagger documentation for activity attachment APIs

Kabiru Mwenjac5456b3c1cc2
diff --git a/docs/api/apiv3/components/schemas/activity_model.yml b/docs/api/apiv3/components/schemas/activity_model.yml
index 6091b519237..b02e62ea4f6 100644
--- a/docs/api/apiv3/components/schemas/activity_model.yml
+++ b/docs/api/apiv3/components/schemas/activity_model.yml
@@ -32,6 +32,60 @@ properties:
format: date-time
description: Time of update
readOnly: true
+ _links:
+ type: object
+ properties:
+ self:
+ allOf:
+ - "$ref": "./link.yml"
+ - description: |-
+ This activity
+
+ **Resource**: Activity
+ readOnly: true
+ workPackage:
+ allOf:
+ - "$ref": "./link.yml"
+ - description: |-
+ The work package this activity belongs to
+
+ **Resource**: WorkPackage
+ readOnly: true
+ user:
+ allOf:
+ - "$ref": "./link.yml"
+ - description: |-
+ The user who created this activity
+
+ **Resource**: User
+ readOnly: true
+ update:
+ allOf:
+ - "$ref": "./link.yml"
+ - description: |-
+ Update this activity
+
+ **Method**: PATCH
+
+ **Resource**: Activity
+ attachments:
+ allOf:
+ - "$ref": "./link.yml"
+ - description: |-
+ The attachment collection of this activity
+
+ **Resource**: AttachmentCollection
+ readOnly: true
+ addAttachment:
+ allOf:
+ - "$ref": "./link.yml"
+ - description: |-
+ Attach a file to the activity
+
+ # Conditions
+
+ **Permission**: add_work_package_notes or add_comments_with_restricted_visibility (for internal comments)
+ readOnly: true
example:
_type: Activity::Comment
_links:
@@ -44,6 +98,14 @@ example:
user:
href: "/api/v3/users/1"
title: John Sheppard - admin
+ attachments:
+ href: "/api/v3/activities/1/attachments"
+ addAttachment:
+ href: "/api/v3/activities/1/attachments"
+ method: post
+ update:
+ href: "/api/v3/activities/1"
+ method: "patch"
id: 1
details:
- format: markdown
diff --git a/docs/api/apiv3/openapi-spec.yml b/docs/api/apiv3/openapi-spec.yml
index e9b469eb0af..da780ff6145 100644
--- a/docs/api/apiv3/openapi-spec.yml
+++ b/docs/api/apiv3/openapi-spec.yml
@@ -166,6 +166,8 @@ paths:
"$ref": "./paths/action.yml"
"/api/v3/activities/{id}":
"$ref": "./paths/activity.yml"
+ "/api/v3/activities/{id}/attachments":
+ "$ref": "./paths/activity_attachments.yml"
"/api/v3/attachments":
"$ref": "./paths/attachments.yml"
"/api/v3/attachments/{id}":
diff --git a/docs/api/apiv3/paths/activity_attachments.yml b/docs/api/apiv3/paths/activity_attachments.yml
new file mode 100644
index 00000000000..bae39a4b928
--- /dev/null
+++ b/docs/api/apiv3/paths/activity_attachments.yml
@@ -0,0 +1,217 @@
+# /api/v3/activities/{id}/attachments
+---
+get:
+ parameters:
+ - description: ID of the activity whose attachments will be listed
+ example: '1'
+ in: path
+ name: id
+ required: true
+ schema:
+ type: integer
+ responses:
+ '200':
+ content:
+ application/hal+json:
+ examples:
+ response:
+ value:
+ _embedded:
+ elements:
+ - _links:
+ self:
+ href: "/api/v3/attachments/30389"
+ title: "Screenshot.png"
+ author:
+ href: "/api/v3/users/435"
+ title: "Test User"
+ staticDownloadLocation:
+ href: "/api/v3/attachments/30389/content"
+ downloadLocation:
+ href: "/api/v3/attachments/30389/content"
+ delete:
+ href: "/api/v3/attachments/30389"
+ method: delete
+ _type: Attachment
+ id: 30389
+ fileName: "Screenshot.png"
+ fileSize: 187760
+ description:
+ format: plain
+ html: ''
+ raw: ''
+ status: "uploaded"
+ contentType: image/png
+ digest:
+ algorithm: md5
+ hash: cdd548290edfc1486c180585889dcea8
+ createdAt: '2025-04-10T11:19:41.821Z'
+ _links:
+ self:
+ href: "/api/v3/activities/79093/attachments"
+ _type: Collection
+ count: 1
+ total: 1
+ schema:
+ "$ref": "../components/schemas/attachments_model.yml"
+ description: OK
+ headers: {}
+ '404':
+ content:
+ application/hal+json:
+ schema:
+ $ref: "../components/schemas/error_response.yml"
+ examples:
+ response:
+ value:
+ _type: Error
+ errorIdentifier: urn:openproject-org:api:v3:errors:NotFound
+ message: The requested resource could not be found.
+ description: |-
+ Returned if the activity does not exist or the client does not have sufficient permissions
+ to see it.
+
+ **Required permission:** view_work_packages or view_comments_with_restricted_visibility (for internal comments)
+
+ *Note: A client without sufficient permissions shall not be able to test for the existence of an activity.
+ That's why a 404 is returned here, even if a 403 might be more appropriate.*
+ headers: {}
+ tags:
+ - Attachments
+ description: ''
+ operationId: List_attachments_by_activity
+ summary: List attachments by activity
+post:
+ parameters:
+ - description: ID of the activity to receive the attachment
+ example: '1'
+ in: path
+ name: id
+ required: true
+ schema:
+ type: integer
+ responses:
+ '200':
+ content:
+ application/hal+json:
+ schema:
+ $ref: "../components/schemas/attachment_model.yml"
+ examples:
+ response:
+ value:
+ _type: Attachment
+ id: 30389
+ fileName: "Screenshot.png"
+ fileSize: 187760
+ description:
+ format: plain
+ html: ''
+ raw: ''
+ status: "uploaded"
+ contentType: image/png
+ digest:
+ algorithm: md5
+ hash: cdd548290edfc1486c180585889dcea8
+ createdAt: '2025-04-10T11:19:41.821Z'
+ _links:
+ self:
+ href: "/api/v3/attachments/30389"
+ title: "Screenshot.png"
+ author:
+ href: "/api/v3/users/435"
+ title: "Test User"
+ staticDownloadLocation:
+ href: "/api/v3/attachments/30389/content"
+ downloadLocation:
+ href: "/api/v3/attachments/30389/content"
+ delete:
+ href: "/api/v3/attachments/30389"
+ method: delete
+ description: OK
+ headers: {}
+ '400':
+ content:
+ application/hal+json:
+ schema:
+ $ref: "../components/schemas/error_response.yml"
+ examples:
+ response:
+ value:
+ _type: Error
+ errorIdentifier: urn:openproject-org:api:v3:errors:InvalidRequestBody
+ message: The request could not be parsed as JSON.
+ description: |-
+ Returned if the client sends a not understandable request. Reasons include:
+
+ * Omitting one of the required parts (metadata and file)
+
+ * sending unparsable JSON in the metadata part
+ headers: {}
+ '403':
+ content:
+ application/hal+json:
+ schema:
+ $ref: "../components/schemas/error_response.yml"
+ examples:
+ response:
+ value:
+ _type: Error
+ errorIdentifier: urn:openproject-org:api:v3:errors:MissingPermission
+ message: You are not allowed to add attachments to this activity.
+ description: |-
+ Returned if the client does not have sufficient permissions.
+
+ **Required permission:** view_work_packages or view_comments_with_restricted_visibility (for internal comments)
+
+ *Note that you will only receive this error, if you are at least allowed to see the activity*
+ headers: {}
+ '404':
+ content:
+ application/hal+json:
+ schema:
+ $ref: "../components/schemas/error_response.yml"
+ examples:
+ response:
+ value:
+ _type: Error
+ errorIdentifier: urn:openproject-org:api:v3:errors:NotFound
+ message: The requested resource could not be found.
+ description: |-
+ Returned if the activity does not exist or the client does not have sufficient permissions
+ to see it.
+
+ **Required permission:** view_work_packages or view_comments_with_restricted_visibility (for internal comments)
+
+ *Note: A client without sufficient permissions shall not be able to test for the existence of an activity.
+ That's why a 404 is returned here, even if a 403 might be more appropriate.*
+ headers: {}
+ '406':
+ $ref: "../components/responses/missing_content_type.yml"
+ '415':
+ $ref: "../components/responses/unsupported_media_type.yml"
+ '422':
+ content:
+ application/hal+json:
+ schema:
+ $ref: "../components/schemas/error_response.yml"
+ examples:
+ response:
+ value:
+ _type: Error
+ errorIdentifier: urn:openproject-org:api:v3:errors:PropertyConstraintViolation
+ message: File is too large (maximum size is 5242880 Bytes).
+ description: |-
+ Returned if the client tries to send an invalid attachment.
+ Reasons are:
+
+ * Omitting the file name (`fileName` property of metadata part)
+
+ * Sending a file that is too large
+ headers: {}
+ tags:
+ - Attachments
+ description: |-
+ Adds an attachment to the activity.
+
+ operationId: Add_attachment_to_activity
+ summary: Add attachment to activity