diff --git a/docs/swagger/paths/v1_short-urls_{shortCode}.json b/docs/swagger/paths/v1_short-urls_{shortCode}.json index 778d0fb1..c312db8a 100644 --- a/docs/swagger/paths/v1_short-urls_{shortCode}.json +++ b/docs/swagger/paths/v1_short-urls_{shortCode}.json @@ -81,7 +81,7 @@ } }, - "put": { + "patch": { "operationId": "editShortUrl", "tags": [ "Short URLs" @@ -169,6 +169,95 @@ } }, + "put": { + "deprecated": true, + "operationId": "editShortUrlPut", + "tags": [ + "Short URLs" + ], + "summary": "[DEPRECATED] Edit short URL", + "description": "**[DEPRECATED]** Use [editShortUrl](#/Short_URLs/getShortUrl) instead", + "parameters": [ + { + "name": "shortCode", + "in": "path", + "description": "The short code to edit.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "Request body.", + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "validSince": { + "description": "The date (in ISO-8601 format) from which this short code will be valid", + "type": "string" + }, + "validUntil": { + "description": "The date (in ISO-8601 format) until which this short code will be valid", + "type": "string" + }, + "maxVisits": { + "description": "The maximum number of allowed visits for this short code", + "type": "number" + } + } + } + } + } + }, + "security": [ + { + "ApiKey": [] + }, + { + "Bearer": [] + } + ], + "responses": { + "204": { + "description": "The short code has been properly updated." + }, + "400": { + "description": "Provided meta arguments are invalid.", + "content": { + "application/json": { + "schema": { + "$ref": "../definitions/Error.json" + } + } + } + }, + "404": { + "description": "No short URL was found for provided short code.", + "content": { + "application/json": { + "schema": { + "$ref": "../definitions/Error.json" + } + } + } + }, + "500": { + "description": "Unexpected error.", + "content": { + "application/json": { + "schema": { + "$ref": "../definitions/Error.json" + } + } + } + } + } + }, + "delete": { "operationId": "deleteShortUrl", "tags": [ diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index 8f996886..6dd3ff8f 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -35,7 +35,7 @@ "name": "X-Api-Key" }, "Bearer": { - "description": "**[Deprecated]** The JWT identifying a previously authenticated API key", + "description": "**[DEPRECATED]** The JWT identifying a previously authenticated API key", "type": "http", "scheme": "bearer", "bearerFormat": "JWT" @@ -66,7 +66,7 @@ }, { "name": "Authentication", - "description": "**[Deprecated]** Authentication-related endpoints" + "description": "**[DEPRECATED]** Authentication-related endpoints" } ], diff --git a/module/Rest/src/Action/ShortUrl/EditShortUrlAction.php b/module/Rest/src/Action/ShortUrl/EditShortUrlAction.php index bd8a8f36..b7bc54ab 100644 --- a/module/Rest/src/Action/ShortUrl/EditShortUrlAction.php +++ b/module/Rest/src/Action/ShortUrl/EditShortUrlAction.php @@ -19,7 +19,7 @@ use function sprintf; class EditShortUrlAction extends AbstractRestAction { protected const ROUTE_PATH = '/short-urls/{shortCode}'; - protected const ROUTE_ALLOWED_METHODS = [self::METHOD_PUT]; + protected const ROUTE_ALLOWED_METHODS = [self::METHOD_PATCH, self::METHOD_PUT]; /** @var ShortUrlServiceInterface */ private $shortUrlService; diff --git a/module/Rest/src/Middleware/CrossDomainMiddleware.php b/module/Rest/src/Middleware/CrossDomainMiddleware.php index b6cead2e..75024b62 100644 --- a/module/Rest/src/Middleware/CrossDomainMiddleware.php +++ b/module/Rest/src/Middleware/CrossDomainMiddleware.php @@ -44,7 +44,7 @@ class CrossDomainMiddleware implements MiddlewareInterface, RequestMethodInterfa // Add OPTIONS-specific headers foreach ([ - 'Access-Control-Allow-Methods' => 'GET,POST,PUT,DELETE,OPTIONS', // TODO Should be dynamic + 'Access-Control-Allow-Methods' => 'GET,POST,PUT,PATCH,DELETE,OPTIONS', // TODO Should be dynamic // 'Access-Control-Allow-Methods' => $response->getHeaderLine('Allow'), 'Access-Control-Max-Age' => '1000', 'Access-Control-Allow-Headers' => $request->getHeaderLine('Access-Control-Request-Headers'),