Created TagsStats endpoint

This commit is contained in:
Alejandro Celaya
2022-01-09 17:24:07 +01:00
parent 397bbe2655
commit d5851bbb6a
8 changed files with 310 additions and 49 deletions

View File

@@ -5,7 +5,7 @@
"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",
"security": [
{
"ApiKey": []
@@ -17,7 +17,8 @@
},
{
"name": "withStats",
"description": "Whether you want to include also a list with general stats by tag or not. Defaults to false.",
"deprecated": true,
"description": "**[Deprecated]** Use [GET /tags/stats](#/Tags/tagsWithStats) endpoint to get tags with their stats.",
"in": "query",
"required": false,
"schema": {
@@ -101,53 +102,20 @@
}
}
},
"examples": {
"Without stats": {
"value": {
"tags": {
"data": [
"games",
"php",
"shlink",
"tech"
],
"pagination": {
"currentPage": 5,
"pagesCount": 10,
"itemsPerPage": 4,
"itemsInCurrentPage": 4,
"totalItems": 38
}
}
}
},
"With stats": {
"value": {
"tags": {
"data": [
"games",
"shlink"
],
"stats": [
{
"tag": "games",
"shortUrlsCount": 10,
"visitsCount": 521
},
{
"tag": "shlink",
"shortUrlsCount": 7,
"visitsCount": 1087
}
],
"pagination": {
"currentPage": 5,
"pagesCount": 5,
"itemsPerPage": 10,
"itemsInCurrentPage": 2,
"totalItems": 42
}
}
"example": {
"tags": {
"data": [
"games",
"php",
"shlink",
"tech"
],
"pagination": {
"currentPage": 5,
"pagesCount": 10,
"itemsPerPage": 4,
"itemsInCurrentPage": 4,
"totalItems": 38
}
}
}

View File

@@ -0,0 +1,123 @@
{
"get": {
"operationId": "tagsWithStats",
"tags": [
"Tags"
],
"summary": "Get tags with stats",
"description": "Returns the list of all tags used in any short URL, together with the amount of short URLs and visits for it",
"security": [
{
"ApiKey": []
}
],
"parameters": [
{
"$ref": "../parameters/version.json"
},
{
"name": "page",
"in": "query",
"description": "The page to display. Defaults to 1",
"required": false,
"schema": {
"type": "number"
}
},
{
"name": "itemsPerPage",
"in": "query",
"description": "The amount of items to return on every page. Defaults to all the items",
"required": false,
"schema": {
"type": "number"
}
},
{
"name": "searchTerm",
"in": "query",
"description": "A query used to filter results by searching for it on the tag name.",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "orderBy",
"in": "query",
"description": "To determine how to order the results.",
"required": false,
"schema": {
"type": "string",
"enum": [
"tag-ASC",
"tag-DESC"
]
}
}
],
"responses": {
"200": {
"description": "The list of tags",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"tags": {
"type": "object",
"required": ["data"],
"properties": {
"data": {
"description": "The tag stats will be returned only if the withStats param was provided with value 'true'",
"type": "array",
"items": {
"$ref": "../definitions/TagInfo.json"
}
},
"pagination": {
"$ref": "../definitions/Pagination.json"
}
}
}
}
},
"example": {
"tags": {
"data": [
{
"tag": "games",
"shortUrlsCount": 10,
"visitsCount": 521
},
{
"tag": "shlink",
"shortUrlsCount": 7,
"visitsCount": 1087
}
],
"pagination": {
"currentPage": 5,
"pagesCount": 5,
"itemsPerPage": 10,
"itemsInCurrentPage": 2,
"totalItems": 42
}
}
}
}
}
},
"default": {
"description": "Unexpected error.",
"content": {
"application/problem+json": {
"schema": {
"$ref": "../definitions/Error.json"
}
}
}
}
}
}
}