Remove old error models and examples from swagger spec

This commit is contained in:
Alejandro Celaya 2024-02-28 08:39:26 +01:00
parent 33729289c7
commit c4805b8152
10 changed files with 19 additions and 78 deletions

View File

@ -1,9 +0,0 @@
{
"value": {
"title": "Invalid data",
"type": "INVALID_ARGUMENT",
"detail": "Provided data is not valid",
"status": 400,
"invalidElements": ["maxVisits", "validSince"]
}
}

View File

@ -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"
}
}

View File

@ -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"
}
}

View File

@ -383,10 +383,10 @@
] ]
}, },
"examples": { "examples": {
"Invalid arguments with API v3 and newer": { "Invalid arguments": {
"$ref": "../examples/short-url-invalid-args-v3.json" "$ref": "../examples/short-url-invalid-args-v3.json"
}, },
"Non-unique slug with API v3 and newer": { "Non-unique slug": {
"value": { "value": {
"title": "Invalid custom slug", "title": "Invalid custom slug",
"type": "https://shlink.io/api/error/non-unique-slug", "type": "https://shlink.io/api/error/non-unique-slug",
@ -394,18 +394,6 @@
"status": 400, "status": 400,
"customSlug": "my-slug" "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"
}
} }
} }
} }

View File

@ -81,11 +81,8 @@
] ]
}, },
"examples": { "examples": {
"API v3 and newer": { "Short URL not found": {
"$ref": "../examples/short-url-not-found-v3.json" "$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": { "examples": {
"API v3 and newer": { "Invalid arguments": {
"$ref": "../examples/short-url-invalid-args-v3.json" "$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": { "examples": {
"API v3 and newer": { "Short URL not found": {
"$ref": "../examples/short-url-not-found-v3.json" "$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": { "examples": {
"API v3 and newer": { "Short URL not found": {
"$ref": "../examples/short-url-not-found-v3.json" "$ref": "../examples/short-url-not-found-v3.json"
},
"Previous to API v3": {
"$ref": "../examples/short-url-not-found-v2.json"
} }
} }
} }

View File

@ -145,11 +145,8 @@
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
}, },
"examples": { "examples": {
"Short URL not found with API v3 and newer": { "Short URL not found": {
"$ref": "../examples/short-url-not-found-v3.json" "$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" "$ref": "../definitions/Error.json"
}, },
"examples": { "examples": {
"Short URL not found with API v3 and newer": { "Short URL not found": {
"$ref": "../examples/short-url-not-found-v3.json" "$ref": "../examples/short-url-not-found-v3.json"
},
"Short URL not found previous to API v3": {
"$ref": "../examples/short-url-not-found-v2.json"
} }
} }
} }

View File

@ -228,9 +228,6 @@
"examples": { "examples": {
"API v3 and newer": { "API v3 and newer": {
"$ref": "../examples/tag-not-found-v3.json" "$ref": "../examples/tag-not-found-v3.json"
},
"Previous to API v3": {
"$ref": "../examples/tag-not-found-v2.json"
} }
} }
} }

View File

@ -148,12 +148,8 @@
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
}, },
"examples": { "examples": {
"Tag not found": {
"API v3 and newer": {
"$ref": "../examples/tag-not-found-v3.json" "$ref": "../examples/tag-not-found-v3.json"
},
"Previous to API v3": {
"$ref": "../examples/tag-not-found-v2.json"
} }
} }
} }

View File

@ -29,7 +29,11 @@
"application/json": { "application/json": {
"schema": { "schema": {
"type": "object", "type": "object",
"required": ["defaultLongUrl", "redirectRules"],
"properties": { "properties": {
"defaultLongUrl": {
"type": "string"
},
"redirectRules": { "redirectRules": {
"type": "array", "type": "array",
"items": { "items": {
@ -39,6 +43,7 @@
} }
}, },
"example": { "example": {
"defaultLongUrl": "https://example.com",
"redirectRules": [ "redirectRules": [
{ {
"longUrl": "https://example.com/android-en-us", "longUrl": "https://example.com/android-en-us",
@ -119,11 +124,8 @@
] ]
}, },
"examples": { "examples": {
"API v3 and newer": { "Short URL not found": {
"$ref": "../examples/short-url-not-found-v3.json" "$ref": "../examples/short-url-not-found-v3.json"
},
"Previous to API v3": {
"$ref": "../examples/short-url-not-found-v2.json"
} }
} }
} }

View File

@ -30,6 +30,9 @@ class ListRedirectRulesAction extends AbstractRestAction
); );
$rules = $this->ruleService->rulesForShortUrl($shortUrl); $rules = $this->ruleService->rulesForShortUrl($shortUrl);
return new JsonResponse(['redirectRules' => $rules]); return new JsonResponse([
'defaultLongUrl' => $shortUrl->getLongUrl(),
'redirectRules' => $rules,
]);
} }
} }