From 0e8c61648938ee2ffa178ca9fea1479b32efee01 Mon Sep 17 00:00:00 2001 From: Kenneth Date: Sun, 28 Dec 2025 19:06:51 +0000 Subject: [PATCH] docs(backend): document PATCH share endpoint --- apps/backend/cmd/docs/openapi.json | 108 +++++++++++++++++++++++++- apps/backend/docs/swagger.json | 86 +++++++++++++++++++- apps/backend/internal/sharing/http.go | 15 ++++ 3 files changed, 204 insertions(+), 5 deletions(-) diff --git a/apps/backend/cmd/docs/openapi.json b/apps/backend/cmd/docs/openapi.json index e68cc39..2a5599d 100644 --- a/apps/backend/cmd/docs/openapi.json +++ b/apps/backend/cmd/docs/openapi.json @@ -301,7 +301,7 @@ "200": { "description": "Trashed directories (when trash=true)", "content": { - "application/json": { + "*/*": { "schema": { "type": "array", "items": { @@ -469,7 +469,7 @@ "200": { "description": "Trashed directory info (when trash=true)", "content": { - "application/json": { + "*/*": { "schema": { "$ref": "#/components/schemas/internal_catalog.DirectoryInfo" } @@ -927,7 +927,7 @@ "200": { "description": "Trashed files (when trash=true)", "content": { - "application/json": { + "*/*": { "schema": { "type": "array", "items": { @@ -1576,6 +1576,95 @@ } } } + }, + "patch": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Update share link details. Omit expiresAt to keep the current value. Use null to remove the expiry.", + "tags": [ + "shares" + ], + "summary": "Update share", + "parameters": [ + { + "description": "Account ID", + "name": "accountID", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "description": "Share ID", + "name": "shareID", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/internal_sharing.patchShareRequest" + } + } + }, + "description": "Share details", + "required": true + }, + "responses": { + "200": { + "description": "Updated share", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/internal_sharing.Share" + } + } + } + }, + "400": { + "description": "Invalid request", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + }, + "401": { + "description": "Not authenticated", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Share not found", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } } }, "/accounts/{accountID}/uploads": { @@ -2533,6 +2622,17 @@ } } }, + "internal_sharing.patchShareRequest": { + "description": "Request to update a share link. Omit expiresAt to keep the current value. Use null to remove the expiry.", + "type": "object", + "properties": { + "expiresAt": { + "description": "Optional expiration time for the share (ISO 8601), null clears it.", + "type": "string", + "example": "2025-01-15T00:00:00Z" + } + } + }, "internal_upload.Status": { "description": "Upload status enumeration", "type": "string", @@ -2634,4 +2734,4 @@ } } } -} +} \ No newline at end of file diff --git a/apps/backend/docs/swagger.json b/apps/backend/docs/swagger.json index 93b0fb5..65a9118 100644 --- a/apps/backend/docs/swagger.json +++ b/apps/backend/docs/swagger.json @@ -1270,6 +1270,79 @@ } } } + }, + "patch": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Update share link details. Omit expiresAt to keep the current value. Use null to remove the expiry.", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "shares" + ], + "summary": "Update share", + "parameters": [ + { + "type": "string", + "format": "uuid", + "description": "Account ID", + "name": "accountID", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Share ID", + "name": "shareID", + "in": "path", + "required": true + }, + { + "description": "Share details", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/internal_sharing.patchShareRequest" + } + } + ], + "responses": { + "200": { + "description": "Updated share", + "schema": { + "$ref": "#/definitions/internal_sharing.Share" + } + }, + "400": { + "description": "Invalid request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "401": { + "description": "Not authenticated", + "schema": { + "type": "string" + } + }, + "404": { + "description": "Share not found", + "schema": { + "type": "string" + } + } + } } }, "/accounts/{accountID}/uploads": { @@ -2131,6 +2204,17 @@ } } }, + "internal_sharing.patchShareRequest": { + "description": "Request to update a share link. Omit expiresAt to keep the current value. Use null to remove the expiry.", + "type": "object", + "properties": { + "expiresAt": { + "description": "Optional expiration time for the share (ISO 8601), null clears it.", + "type": "string", + "example": "2025-01-15T00:00:00Z" + } + } + }, "internal_upload.Status": { "description": "Upload status enumeration", "type": "string", @@ -2239,4 +2323,4 @@ "in": "header" } } -} +} \ No newline at end of file diff --git a/apps/backend/internal/sharing/http.go b/apps/backend/internal/sharing/http.go index 3eb48b4..b501a43 100644 --- a/apps/backend/internal/sharing/http.go +++ b/apps/backend/internal/sharing/http.go @@ -225,6 +225,21 @@ func (h *HTTPHandler) createShare(c *fiber.Ctx) error { return c.JSON(share) } +// updateShare updates a share link +// @Summary Update share +// @Description Update share link details. Omit expiresAt to keep the current value. Use null to remove the expiry. +// @Tags shares +// @Accept json +// @Produce json +// @Param accountID path string true "Account ID" format(uuid) +// @Param shareID path string true "Share ID" +// @Param request body patchShareRequest true "Share details" +// @Success 200 {object} Share "Updated share" +// @Failure 400 {object} map[string]string "Invalid request" +// @Failure 401 {string} string "Not authenticated" +// @Failure 404 {string} string "Share not found" +// @Security BearerAuth +// @Router /accounts/{accountID}/shares/{shareID} [patch] func (h *HTTPHandler) updateShare(c *fiber.Ctx) error { shareID := c.Params("shareID")