From 192308a6a3cb6997caac319257d5c02f605be2ab Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 25 Jul 2021 18:46:48 +0200 Subject: [PATCH] Added swagger docs for endpoint do edit domain redirects --- .../definitions/NotFoundRedirects.json | 20 +++++ docs/swagger/paths/v2_domains_redirects.json | 81 +++++++++++++++++++ docs/swagger/swagger.json | 5 +- 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 docs/swagger/definitions/NotFoundRedirects.json create mode 100644 docs/swagger/paths/v2_domains_redirects.json diff --git a/docs/swagger/definitions/NotFoundRedirects.json b/docs/swagger/definitions/NotFoundRedirects.json new file mode 100644 index 00000000..6887ed0c --- /dev/null +++ b/docs/swagger/definitions/NotFoundRedirects.json @@ -0,0 +1,20 @@ +{ + "type": "object", + "properties": { + "baseUrlRedirect": { + "type": "string", + "nullable": true, + "description": "URL to redirect to when a user hits the domain's base URL" + }, + "regular404Redirect": { + "type": "string", + "nullable": true, + "description": "URL to redirect to when a user hits a not found URL other than an invalid short URL" + }, + "invalidShortUrlRedirect": { + "type": "string", + "nullable": true, + "description": "URL to redirect to when a user hits an invalid short URL" + } + } +} diff --git a/docs/swagger/paths/v2_domains_redirects.json b/docs/swagger/paths/v2_domains_redirects.json new file mode 100644 index 00000000..0868504e --- /dev/null +++ b/docs/swagger/paths/v2_domains_redirects.json @@ -0,0 +1,81 @@ +{ + "patch": { + "operationId": "setDomainRedirects", + "tags": [ + "Domains" + ], + "summary": "Sets domain \"not found\" redirects", + "description": "Sets the URLs that you want a visitor to get redirected to for \not found\" URLs for a specific domain", + "security": [ + { + "ApiKey": [] + } + ], + "parameters": [ + { + "$ref": "../parameters/version.json" + } + ], + "requestBody": { + "description": "Request body.", + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "allOf": [ + { + "required": ["domain"], + "properties": { + "domain": { + "description": "The domain's authority for which you want to set redirects", + "type": "string" + } + } + }, + { + "$ref": "../definitions/NotFoundRedirects.json" + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "The domain's redirects after the update, when existing redirects have been merged with provided ones.", + "content": { + "application/json": { + "schema": { + "allOf": [ + { + "required": ["baseUrlRedirect", "regular404Redirect", "invalidShortUrlRedirect"] + }, + { + "$ref": "../definitions/NotFoundRedirects.json" + } + ] + } + } + }, + "examples": { + "application/json": { + "baseUrlRedirect": "https://example.com/my-landing-page", + "regular404Redirect": null, + "invalidShortUrlRedirect": "https://example.com/invalid-url" + } + } + }, + "500": { + "description": "Unexpected error.", + "content": { + "application/problem+json": { + "schema": { + "$ref": "../definitions/Error.json" + } + } + } + } + } + } +} diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index 21547f90..705069cc 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -1,5 +1,5 @@ { - "openapi": "3.0.0", + "openapi": "3.0.3", "info": { "title": "Shlink", "description": "Shlink, the self-hosted URL shortener", @@ -102,6 +102,9 @@ "/rest/v{version}/domains": { "$ref": "paths/v2_domains.json" }, + "/rest/v{version}/domains/redirects": { + "$ref": "paths/v2_domains_redirects.json" + }, "/rest/v{version}/mercure-info": { "$ref": "paths/v2_mercure-info.json"