Merge branch 'develop'

This commit is contained in:
Alejandro Celaya 2018-02-03 10:23:18 +01:00
commit 86ed83d25e
8 changed files with 496 additions and 279 deletions

View File

@ -1,7 +0,0 @@
{
"name": "Authorization",
"in": "header",
"description": "The authorization token with Bearer type",
"required": true,
"type": "string"
}

View File

@ -5,18 +5,31 @@
], ],
"summary": "Perform authentication", "summary": "Perform authentication",
"description": "Performs an authentication", "description": "Performs an authentication",
"parameters": [ "requestBody": {
{ "description": "Request body.",
"name": "apiKey",
"in": "formData",
"description": "The API key to authenticate with",
"required": true, "required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"apiKey"
],
"properties": {
"apiKey": {
"description": "The API key to authenticate with",
"type": "string" "type": "string"
} }
], }
}
}
}
},
"responses": { "responses": {
"200": { "200": {
"description": "The authentication worked.", "description": "The authentication worked.",
"content": {
"application/json": {
"schema": { "schema": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -25,6 +38,8 @@
"description": "The authentication token that needs to be sent in the Authorization header" "description": "The authentication token that needs to be sent in the Authorization header"
} }
} }
}
}
}, },
"examples": { "examples": {
"application/json": { "application/json": {
@ -34,22 +49,34 @@
}, },
"400": { "400": {
"description": "An API key was not provided.", "description": "An API key was not provided.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
}
}
}, },
"401": { "401": {
"description": "The API key is incorrect, is disabled or has expired.", "description": "The API key is incorrect, is disabled or has expired.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
}
}
}, },
"500": { "500": {
"description": "Unexpected error.", "description": "Unexpected error.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
} }
} }
} }
}
}
} }

View File

@ -11,45 +11,57 @@
"in": "query", "in": "query",
"description": "The page to be displayed. Defaults to 1", "description": "The page to be displayed. Defaults to 1",
"required": false, "required": false,
"schema": {
"type": "integer" "type": "integer"
}
}, },
{ {
"name": "searchTerm", "name": "searchTerm",
"in": "query", "in": "query",
"description": "A query used to filter results by searching for it on the longUrl and shortCode fields. (Since v1.3.0)", "description": "A query used to filter results by searching for it on the longUrl and shortCode fields. (Since v1.3.0)",
"required": false, "required": false,
"schema": {
"type": "string" "type": "string"
}
}, },
{ {
"name": "tags", "name": "tags",
"in": "query", "in": "query",
"description": "A list of tags used to filter the resultset. Only short URLs tagged with at least one of the provided tags will be returned. (Since v1.3.0)", "description": "A list of tags used to filter the resultset. Only short URLs tagged with at least one of the provided tags will be returned. (Since v1.3.0)",
"required": false, "required": false,
"schema": {
"type": "array", "type": "array",
"items": { "items": {
"type": "string" "type": "string"
} }
}
}, },
{ {
"name": "orderBy", "name": "orderBy",
"in": "query", "in": "query",
"description": "The field from which you want to order the result. (Since v1.3.0)", "description": "The field from which you want to order the result. (Since v1.3.0)",
"required": false,
"schema": {
"type": "string",
"enum": [ "enum": [
"originalUrl", "originalUrl",
"shortCode", "shortCode",
"dateCreated", "dateCreated",
"visits" "visits"
]
}
}
], ],
"required": false, "security": [
"type": "string"
},
{ {
"$ref": "../parameters/Authorization.json" "Bearer": []
} }
], ],
"responses": { "responses": {
"200": { "200": {
"description": "The list of short URLs", "description": "The list of short URLs",
"content": {
"application/json": {
"schema": { "schema": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -68,6 +80,8 @@
} }
} }
} }
}
}
}, },
"examples": { "examples": {
"application/json": { "application/json": {
@ -110,11 +124,15 @@
}, },
"500": { "500": {
"description": "Unexpected error.", "description": "Unexpected error.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
} }
} }
}
}
}, },
"post": { "post": {
@ -123,59 +141,59 @@
], ],
"summary": "Create short URL", "summary": "Create short URL",
"description": "Creates a new short code", "description": "Creates a new short code",
"parameters": [ "security": [
{ {
"name": "longUrl", "Bearer": []
"in": "formData", }
"description": "The URL to parse", ],
"requestBody": {
"description": "Request body.",
"required": true, "required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"longUrl"
],
"properties": {
"longUrl": {
"description": "The URL to parse",
"type": "string" "type": "string"
}, },
{ "tags": {
"name": "tags",
"in": "formData",
"description": "The URL to parse", "description": "The URL to parse",
"required": false,
"type": "array", "type": "array",
"items": { "items": {
"type": "string" "type": "string"
} }
}, },
{ "validSince": {
"name": "validSince",
"in": "formData",
"description": "The date (in ISO-8601 format) from which this short code will be valid", "description": "The date (in ISO-8601 format) from which this short code will be valid",
"required": false,
"type": "string" "type": "string"
}, },
{ "validUntil": {
"name": "validUntil",
"in": "formData",
"description": "The date (in ISO-8601 format) until which this short code will be valid", "description": "The date (in ISO-8601 format) until which this short code will be valid",
"required": false,
"type": "string" "type": "string"
}, },
{ "customSlug": {
"name": "customSlug",
"in": "formData",
"description": "A unique custom slug to be used instead of the generated short code", "description": "A unique custom slug to be used instead of the generated short code",
"required": false,
"type": "string" "type": "string"
}, },
{ "maxVisits": {
"name": "maxVisits",
"in": "formData",
"description": "The maximum number of allowed visits for this short code", "description": "The maximum number of allowed visits for this short code",
"required": false,
"type": "number" "type": "number"
},
{
"$ref": "../parameters/Authorization.json"
} }
], }
}
}
}
},
"responses": { "responses": {
"200": { "200": {
"description": "The result of parsing the long URL", "description": "The result of parsing the long URL",
"content": {
"application/json": {
"schema": { "schema": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -193,19 +211,29 @@
} }
} }
} }
}
}
}, },
"400": { "400": {
"description": "The long URL was not provided or is invalid.", "description": "The long URL was not provided or is invalid.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
}
}
}, },
"500": { "500": {
"description": "Unexpected error.", "description": "Unexpected error.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
} }
} }
} }
}
}
} }

View File

@ -9,17 +9,23 @@
{ {
"name": "shortCode", "name": "shortCode",
"in": "path", "in": "path",
"type": "string",
"description": "The short code to resolve.", "description": "The short code to resolve.",
"required": true "required": true,
}, "schema": {
"type": "string"
}
}
],
"security": [
{ {
"$ref": "../parameters/Authorization.json" "Bearer": []
} }
], ],
"responses": { "responses": {
"200": { "200": {
"description": "The long URL behind a short code.", "description": "The long URL behind a short code.",
"content": {
"application/json": {
"schema": { "schema": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -28,6 +34,8 @@
"description": "The original long URL behind the short code." "description": "The original long URL behind the short code."
} }
} }
}
}
}, },
"examples": { "examples": {
"application/json": { "application/json": {
@ -37,23 +45,35 @@
}, },
"400": { "400": {
"description": "Provided shortCode does not match the character set currently used by the app to generate short codes.", "description": "Provided shortCode does not match the character set currently used by the app to generate short codes.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
}
}
}, },
"404": { "404": {
"description": "No URL was found for provided short code.", "description": "No URL was found for provided short code.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
}
}
}, },
"500": { "500": {
"description": "Unexpected error.", "description": "Unexpected error.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
} }
} }
}
}
}, },
"put": { "put": {
@ -66,33 +86,41 @@
{ {
"name": "shortCode", "name": "shortCode",
"in": "path", "in": "path",
"type": "string",
"description": "The short code to edit.", "description": "The short code to edit.",
"required": true "required": true,
}, "schema": {
{ "type": "string"
"name": "validSince", }
"in": "formData", }
],
"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", "description": "The date (in ISO-8601 format) from which this short code will be valid",
"required": false,
"type": "string" "type": "string"
}, },
{ "validUntil": {
"name": "validUntil",
"in": "formData",
"description": "The date (in ISO-8601 format) until which this short code will be valid", "description": "The date (in ISO-8601 format) until which this short code will be valid",
"required": false,
"type": "string" "type": "string"
}, },
{ "maxVisits": {
"name": "maxVisits",
"in": "formData",
"description": "The maximum number of allowed visits for this short code", "description": "The maximum number of allowed visits for this short code",
"required": false,
"type": "number" "type": "number"
}
}
}
}
}
}, },
"security": [
{ {
"$ref": "../parameters/Authorization.json" "Bearer": []
} }
], ],
"responses": { "responses": {
@ -101,22 +129,34 @@
}, },
"400": { "400": {
"description": "Provided meta arguments are invalid.", "description": "Provided meta arguments are invalid.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
}
}
}, },
"404": { "404": {
"description": "No short URL was found for provided short code.", "description": "No short URL was found for provided short code.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
}
}
}, },
"500": { "500": {
"description": "Unexpected error.", "description": "Unexpected error.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
} }
} }
} }
}
}
} }

View File

@ -10,27 +10,46 @@
{ {
"name": "shortCode", "name": "shortCode",
"in": "path", "in": "path",
"type": "string",
"description": "The shortCode in which we want to edit tags.", "description": "The shortCode in which we want to edit tags.",
"required": true "required": true,
}, "schema": {
{ "type": "string"
"name": "tags", }
"in": "formData", }
],
"requestBody": {
"description": "Request body.",
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"tags"
],
"properties": {
"tags": {
"type": "array", "type": "array",
"items": { "items": {
"type": "string" "type": "string"
}, },
"description": "The list of tags to set to the short URL.", "description": "The list of tags to set to the short URL."
"required": true }
}
}
}
}
}, },
"security": [
{ {
"$ref": "../parameters/Authorization.json" "Bearer": []
} }
], ],
"responses": { "responses": {
"200": { "200": {
"description": "List of tags.", "description": "List of tags.",
"content": {
"application/json": {
"schema": { "schema": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -41,6 +60,8 @@
} }
} }
} }
}
}
}, },
"examples": { "examples": {
"application/json": { "application/json": {
@ -53,22 +74,34 @@
}, },
"400": { "400": {
"description": "The request body does not contain a \"tags\" param with array type.", "description": "The request body does not contain a \"tags\" param with array type.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
}
}
}, },
"404": { "404": {
"description": "No short URL was found for provided short code.", "description": "No short URL was found for provided short code.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
}
}
}, },
"500": { "500": {
"description": "Unexpected error.", "description": "Unexpected error.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
} }
} }
} }
}
}
} }

View File

@ -10,17 +10,23 @@
{ {
"name": "shortCode", "name": "shortCode",
"in": "path", "in": "path",
"type": "string",
"description": "The shortCode from which we want to get the visits.", "description": "The shortCode from which we want to get the visits.",
"required": true "required": true,
}, "schema": {
"type": "string"
}
}
],
"security": [
{ {
"$ref": "../parameters/Authorization.json" "Bearer": []
} }
], ],
"responses": { "responses": {
"200": { "200": {
"description": "List of visits.", "description": "List of visits.",
"content": {
"application/json": {
"schema": { "schema": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -36,6 +42,8 @@
} }
} }
} }
}
}
}, },
"examples": { "examples": {
"application/json": { "application/json": {
@ -66,16 +74,24 @@
}, },
"404": { "404": {
"description": "The short code does not belong to any short URL.", "description": "The short code does not belong to any short URL.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
}
}
}, },
"500": { "500": {
"description": "Unexpected error.", "description": "Unexpected error.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
} }
} }
} }
}
}
} }

View File

@ -5,14 +5,16 @@
], ],
"summary": "List existing tags", "summary": "List existing tags",
"description": "Returns the list of all tags used in any short URL, ordered by name", "description": "Returns the list of all tags used in any short URL, ordered by name",
"parameters": [ "security": [
{ {
"$ref": "../parameters/Authorization.json" "Bearer": []
} }
], ],
"responses": { "responses": {
"200": { "200": {
"description": "The list of tags", "description": "The list of tags",
"content": {
"application/json": {
"schema": { "schema": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -28,6 +30,8 @@
} }
} }
} }
}
}
}, },
"examples": { "examples": {
"application/json": { "application/json": {
@ -44,11 +48,15 @@
}, },
"500": { "500": {
"description": "Unexpected error.", "description": "Unexpected error.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
} }
} }
}
}
}, },
"post": { "post": {
@ -57,21 +65,39 @@
], ],
"summary": "Create tags", "summary": "Create tags",
"description": "Provided a list of tags, creates all that do not yet exist", "description": "Provided a list of tags, creates all that do not yet exist",
"parameters": [ "security": [
{ {
"$ref": "../parameters/Authorization.json" "Bearer": []
},
{
"name": "tags[]",
"in": "formData",
"description": "The list of tag names to create",
"required": true,
"type": "array"
} }
], ],
"requestBody": {
"description": "Request body.",
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"tags"
],
"properties": {
"tags": {
"description": "The list of tag names to create",
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
},
"responses": { "responses": {
"200": { "200": {
"description": "The list of tags", "description": "The list of tags",
"content": {
"application/json": {
"schema": { "schema": {
"type": "object", "type": "object",
"properties": { "properties": {
@ -87,6 +113,8 @@
} }
} }
} }
}
}
}, },
"examples": { "examples": {
"application/json": { "application/json": {
@ -103,11 +131,15 @@
}, },
"500": { "500": {
"description": "Unexpected error.", "description": "Unexpected error.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
} }
} }
}
}
}, },
"put": { "put": {
@ -116,48 +148,71 @@
], ],
"summary": "Rename tag", "summary": "Rename tag",
"description": "Renames one existing tag", "description": "Renames one existing tag",
"parameters": [ "security": [
{ {
"$ref": "../parameters/Authorization.json" "Bearer": []
},
{
"name": "oldName",
"in": "formData",
"description": "Current name of the tag",
"required": true,
"type": "string"
},
{
"name": "newName",
"in": "formData",
"description": "New name of the tag",
"required": true,
"type": "string"
} }
], ],
"requestBody": {
"description": "Request body.",
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"oldName",
"newName"
],
"properties": {
"oldName": {
"description": "Current name of the tag",
"type": "string"
},
"newName": {
"description": "New name of the tag",
"type": "string"
}
}
}
}
}
},
"responses": { "responses": {
"204": { "204": {
"description": "The tag has been properly renamed" "description": "The tag has been properly renamed"
}, },
"400": { "400": {
"description": "You have not provided either the oldName or the newName params.", "description": "You have not provided either the oldName or the newName params.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
}
}
}, },
"404": { "404": {
"description": "There's no tag found with the name provided in oldName param.", "description": "There's no tag found with the name provided in oldName param.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
}
}
}, },
"500": { "500": {
"description": "Unexpected error.", "description": "Unexpected error.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
} }
} }
}
}
}, },
"delete": { "delete": {
@ -167,15 +222,22 @@
"summary": "Delete tags", "summary": "Delete tags",
"description": "Deletes provided list of tags", "description": "Deletes provided list of tags",
"parameters": [ "parameters": [
{
"$ref": "../parameters/Authorization.json"
},
{ {
"name": "tags[]", "name": "tags[]",
"in": "query", "in": "query",
"description": "The names of the tags to delete", "description": "The names of the tags to delete",
"required": true, "required": true,
"type": "array" "schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
],
"security": [
{
"Bearer": []
} }
], ],
"responses": { "responses": {
@ -184,10 +246,14 @@
}, },
"500": { "500": {
"description": "Unexpected error.", "description": "Unexpected error.",
"content": {
"application/json": {
"schema": { "schema": {
"$ref": "../definitions/Error.json" "$ref": "../definitions/Error.json"
} }
} }
} }
} }
}
}
} }

View File

@ -1,23 +1,37 @@
{ {
"swagger": "2.0", "openapi": "3.0.0",
"info": { "info": {
"title": "Shlink", "title": "Shlink",
"description": "Shlink, the self-hosted URL shortener", "description": "Shlink, the self-hosted URL shortener",
"version": "1.0" "version": "1.0"
}, },
"schemes": [
"http", "servers": [
"https" {
], "url": "{schema}://{server}/rest",
"basePath": "/rest", "variables": {
"produces": [ "schema": {
"application/json" "default": "https",
], "enum": ["https", "http"]
"consumes": [ },
"application/x-www-form-urlencoded", "server": {
"application/json" "default": ""
}
}
}
], ],
"components": {
"securitySchemes": {
"Bearer": {
"description": "The JWT identifying a previously logged API key",
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT"
}
}
},
"paths": { "paths": {
"/v1/authenticate": { "/v1/authenticate": {
"$ref": "paths/v1_authenticate.json" "$ref": "paths/v1_authenticate.json"