From c4805b8152809cb0ffb240b3f61d246ea93a6651 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 28 Feb 2024 08:39:26 +0100 Subject: [PATCH] Remove old error models and examples from swagger spec --- .../examples/short-url-invalid-args-v2.json | 9 --------- .../examples/short-url-not-found-v2.json | 9 --------- docs/swagger/examples/tag-not-found-v2.json | 9 --------- docs/swagger/paths/v1_short-urls.json | 16 ++------------- .../paths/v1_short-urls_{shortCode}.json | 20 ++++--------------- .../v1_short-urls_{shortCode}_visits.json | 10 ++-------- docs/swagger/paths/v1_tags.json | 3 --- docs/swagger/paths/v2_tags_{tag}_visits.json | 6 +----- ...short-urls_{shortCode}_redirect-rules.json | 10 ++++++---- .../RedirectRule/ListRedirectRulesAction.php | 5 ++++- 10 files changed, 19 insertions(+), 78 deletions(-) delete mode 100644 docs/swagger/examples/short-url-invalid-args-v2.json delete mode 100644 docs/swagger/examples/short-url-not-found-v2.json delete mode 100644 docs/swagger/examples/tag-not-found-v2.json diff --git a/docs/swagger/examples/short-url-invalid-args-v2.json b/docs/swagger/examples/short-url-invalid-args-v2.json deleted file mode 100644 index d85a5eed..00000000 --- a/docs/swagger/examples/short-url-invalid-args-v2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "value": { - "title": "Invalid data", - "type": "INVALID_ARGUMENT", - "detail": "Provided data is not valid", - "status": 400, - "invalidElements": ["maxVisits", "validSince"] - } -} diff --git a/docs/swagger/examples/short-url-not-found-v2.json b/docs/swagger/examples/short-url-not-found-v2.json deleted file mode 100644 index 4a58c847..00000000 --- a/docs/swagger/examples/short-url-not-found-v2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "value": { - "detail": "No URL found with short code \"abc123\"", - "title": "Short URL not found", - "type": "INVALID_SHORTCODE", - "status": 404, - "shortCode": "abc123" - } -} diff --git a/docs/swagger/examples/tag-not-found-v2.json b/docs/swagger/examples/tag-not-found-v2.json deleted file mode 100644 index 46018121..00000000 --- a/docs/swagger/examples/tag-not-found-v2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "value": { - "detail": "Tag with name \"foo\" could not be found", - "title": "Tag not found", - "type": "TAG_NOT_FOUND", - "status": 404, - "tag": "foo" - } -} diff --git a/docs/swagger/paths/v1_short-urls.json b/docs/swagger/paths/v1_short-urls.json index 150eebc0..7d172ff4 100644 --- a/docs/swagger/paths/v1_short-urls.json +++ b/docs/swagger/paths/v1_short-urls.json @@ -383,10 +383,10 @@ ] }, "examples": { - "Invalid arguments with API v3 and newer": { + "Invalid arguments": { "$ref": "../examples/short-url-invalid-args-v3.json" }, - "Non-unique slug with API v3 and newer": { + "Non-unique slug": { "value": { "title": "Invalid custom slug", "type": "https://shlink.io/api/error/non-unique-slug", @@ -394,18 +394,6 @@ "status": 400, "customSlug": "my-slug" } - }, - "Invalid arguments previous to API v3": { - "$ref": "../examples/short-url-invalid-args-v2.json" - }, - "Non-unique slug previous to API v3": { - "value": { - "title": "Invalid custom slug", - "type": "INVALID_SLUG", - "detail": "Provided slug \"my-slug\" is already in use.", - "status": 400, - "customSlug": "my-slug" - } } } } diff --git a/docs/swagger/paths/v1_short-urls_{shortCode}.json b/docs/swagger/paths/v1_short-urls_{shortCode}.json index 120dc43e..c1a6eafc 100644 --- a/docs/swagger/paths/v1_short-urls_{shortCode}.json +++ b/docs/swagger/paths/v1_short-urls_{shortCode}.json @@ -81,11 +81,8 @@ ] }, "examples": { - "API v3 and newer": { + "Short URL not found": { "$ref": "../examples/short-url-not-found-v3.json" - }, - "Previous to API v3": { - "$ref": "../examples/short-url-not-found-v2.json" } } } @@ -202,11 +199,8 @@ ] }, "examples": { - "API v3 and newer": { + "Invalid arguments": { "$ref": "../examples/short-url-invalid-args-v3.json" - }, - "Previous to API v3": { - "$ref": "../examples/short-url-invalid-args-v2.json" } } } @@ -238,11 +232,8 @@ ] }, "examples": { - "API v3 and newer": { + "Short URL not found": { "$ref": "../examples/short-url-not-found-v3.json" - }, - "Previous to API v3": { - "$ref": "../examples/short-url-not-found-v2.json" } } } @@ -368,11 +359,8 @@ ] }, "examples": { - "API v3 and newer": { + "Short URL not found": { "$ref": "../examples/short-url-not-found-v3.json" - }, - "Previous to API v3": { - "$ref": "../examples/short-url-not-found-v2.json" } } } diff --git a/docs/swagger/paths/v1_short-urls_{shortCode}_visits.json b/docs/swagger/paths/v1_short-urls_{shortCode}_visits.json index 2f102711..71e70148 100644 --- a/docs/swagger/paths/v1_short-urls_{shortCode}_visits.json +++ b/docs/swagger/paths/v1_short-urls_{shortCode}_visits.json @@ -145,11 +145,8 @@ "$ref": "../definitions/Error.json" }, "examples": { - "Short URL not found with API v3 and newer": { + "Short URL not found": { "$ref": "../examples/short-url-not-found-v3.json" - }, - "Short URL not found previous to API v3": { - "$ref": "../examples/short-url-not-found-v2.json" } } } @@ -219,11 +216,8 @@ "$ref": "../definitions/Error.json" }, "examples": { - "Short URL not found with API v3 and newer": { + "Short URL not found": { "$ref": "../examples/short-url-not-found-v3.json" - }, - "Short URL not found previous to API v3": { - "$ref": "../examples/short-url-not-found-v2.json" } } } diff --git a/docs/swagger/paths/v1_tags.json b/docs/swagger/paths/v1_tags.json index b4f6ef89..752797c8 100644 --- a/docs/swagger/paths/v1_tags.json +++ b/docs/swagger/paths/v1_tags.json @@ -228,9 +228,6 @@ "examples": { "API v3 and newer": { "$ref": "../examples/tag-not-found-v3.json" - }, - "Previous to API v3": { - "$ref": "../examples/tag-not-found-v2.json" } } } diff --git a/docs/swagger/paths/v2_tags_{tag}_visits.json b/docs/swagger/paths/v2_tags_{tag}_visits.json index d40b7020..2a0148ec 100644 --- a/docs/swagger/paths/v2_tags_{tag}_visits.json +++ b/docs/swagger/paths/v2_tags_{tag}_visits.json @@ -148,12 +148,8 @@ "$ref": "../definitions/Error.json" }, "examples": { - - "API v3 and newer": { + "Tag not found": { "$ref": "../examples/tag-not-found-v3.json" - }, - "Previous to API v3": { - "$ref": "../examples/tag-not-found-v2.json" } } } diff --git a/docs/swagger/paths/v3_short-urls_{shortCode}_redirect-rules.json b/docs/swagger/paths/v3_short-urls_{shortCode}_redirect-rules.json index da4e95f5..3854e2b9 100644 --- a/docs/swagger/paths/v3_short-urls_{shortCode}_redirect-rules.json +++ b/docs/swagger/paths/v3_short-urls_{shortCode}_redirect-rules.json @@ -29,7 +29,11 @@ "application/json": { "schema": { "type": "object", + "required": ["defaultLongUrl", "redirectRules"], "properties": { + "defaultLongUrl": { + "type": "string" + }, "redirectRules": { "type": "array", "items": { @@ -39,6 +43,7 @@ } }, "example": { + "defaultLongUrl": "https://example.com", "redirectRules": [ { "longUrl": "https://example.com/android-en-us", @@ -119,11 +124,8 @@ ] }, "examples": { - "API v3 and newer": { + "Short URL not found": { "$ref": "../examples/short-url-not-found-v3.json" - }, - "Previous to API v3": { - "$ref": "../examples/short-url-not-found-v2.json" } } } diff --git a/module/Rest/src/Action/RedirectRule/ListRedirectRulesAction.php b/module/Rest/src/Action/RedirectRule/ListRedirectRulesAction.php index c4db3e12..c4d9754e 100644 --- a/module/Rest/src/Action/RedirectRule/ListRedirectRulesAction.php +++ b/module/Rest/src/Action/RedirectRule/ListRedirectRulesAction.php @@ -30,6 +30,9 @@ class ListRedirectRulesAction extends AbstractRestAction ); $rules = $this->ruleService->rulesForShortUrl($shortUrl); - return new JsonResponse(['redirectRules' => $rules]); + return new JsonResponse([ + 'defaultLongUrl' => $shortUrl->getLongUrl(), + 'redirectRules' => $rules, + ]); } }