189 lines
4.0 KiB
JSON
189 lines
4.0 KiB
JSON
{
|
|
"swagger": "2.0",
|
|
"info": {
|
|
"title": "Short URL Gateway",
|
|
"description": "Service for generating, retrieving, and deleting short URLs",
|
|
"version": "0.0.1"
|
|
},
|
|
"host": "127.0.0.1:8888",
|
|
"schemes": [
|
|
"http",
|
|
"https"
|
|
],
|
|
"consumes": [
|
|
"application/json"
|
|
],
|
|
"produces": [
|
|
"application/json"
|
|
],
|
|
"paths": {
|
|
"/api/v1/url/": {
|
|
"post": {
|
|
"summary": "Create Short URL",
|
|
"description": "Map a long URL to a short URL",
|
|
"operationId": "createShortURL",
|
|
"responses": {
|
|
"200": {
|
|
"description": "A successful response.",
|
|
"schema": {
|
|
"$ref": "#/definitions/URLCodeResponse"
|
|
}
|
|
}
|
|
},
|
|
"parameters": [
|
|
{
|
|
"name": "body",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/CreateShortURLRequest"
|
|
}
|
|
}
|
|
],
|
|
"tags": [
|
|
"url"
|
|
]
|
|
}
|
|
},
|
|
"/api/v1/url/{short_code}": {
|
|
"get": {
|
|
"summary": "Retrieve Short URL",
|
|
"description": "Retrieve the original URL using the short URL",
|
|
"operationId": "getOriginalURL",
|
|
"responses": {
|
|
"200": {
|
|
"description": "A successful response.",
|
|
"schema": {
|
|
"$ref": "#/definitions/URLResponse"
|
|
}
|
|
}
|
|
},
|
|
"parameters": [
|
|
{
|
|
"name": "short_code",
|
|
"in": "path",
|
|
"required": true,
|
|
"type": "string"
|
|
}
|
|
],
|
|
"tags": [
|
|
"url"
|
|
]
|
|
},
|
|
"delete": {
|
|
"summary": "Delete Short URL",
|
|
"description": "Delete a short URL mapping",
|
|
"operationId": "deleteShortURL",
|
|
"responses": {
|
|
"200": {
|
|
"description": "A successful response.",
|
|
"schema": {
|
|
"$ref": "#/definitions/RespOK"
|
|
}
|
|
}
|
|
},
|
|
"parameters": [
|
|
{
|
|
"name": "short_code",
|
|
"in": "path",
|
|
"required": true,
|
|
"type": "string"
|
|
},
|
|
{
|
|
"name": "body",
|
|
"in": "body",
|
|
"required": true,
|
|
"schema": {
|
|
"$ref": "#/definitions/URLRequest"
|
|
}
|
|
}
|
|
],
|
|
"tags": [
|
|
"url"
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"definitions": {
|
|
"CreateShortURLRequest": {
|
|
"type": "object",
|
|
"properties": {
|
|
"url": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"title": "CreateShortURLRequest",
|
|
"required": [
|
|
"url"
|
|
]
|
|
},
|
|
"RespOK": {
|
|
"type": "object",
|
|
"title": "RespOK"
|
|
},
|
|
"Status": {
|
|
"type": "object",
|
|
"properties": {
|
|
"code": {
|
|
"type": "integer",
|
|
"format": "int64",
|
|
"description": " 狀態碼"
|
|
},
|
|
"message": {
|
|
"type": "string",
|
|
"description": " 訊息"
|
|
},
|
|
"data": {
|
|
"type": "object",
|
|
"description": " 可選的資料,當有返回時才出現"
|
|
},
|
|
"error": {
|
|
"type": "object",
|
|
"description": " 可選的錯誤信息"
|
|
}
|
|
},
|
|
"title": "Status",
|
|
"required": [
|
|
"code",
|
|
"message"
|
|
]
|
|
},
|
|
"URLCodeResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"short_code": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"title": "URLCodeResponse",
|
|
"required": [
|
|
"short_code"
|
|
]
|
|
},
|
|
"URLRequest": {
|
|
"type": "object",
|
|
"title": "URLRequest"
|
|
},
|
|
"URLResponse": {
|
|
"type": "object",
|
|
"properties": {
|
|
"url": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"title": "URLResponse",
|
|
"required": [
|
|
"url"
|
|
]
|
|
}
|
|
},
|
|
"securityDefinitions": {
|
|
"apiKey": {
|
|
"type": "apiKey",
|
|
"description": "Enter JWT Bearer token **_only_**",
|
|
"name": "Authorization",
|
|
"in": "header"
|
|
}
|
|
}
|
|
}
|