Leonid Nikitin
9bfd3fef1a
Added Swagger as a new service in the docker-compose file for generating the API documentation. The new API documentation is provided via an OpenAPI file located at `public/swagger.json`. Changes in routing were done to handle /api-docs requests and redirect them to the running Swagger UI instance. This will make API easier to understand and debug.
227 lines
7.4 KiB
JSON
227 lines
7.4 KiB
JSON
{
|
|
"openapi": "3.0.3",
|
|
"info": {
|
|
"title": "Captcha service - API",
|
|
"description": "API Documentation.",
|
|
"version": "1.0.0"
|
|
},
|
|
"servers": [
|
|
{
|
|
"url": "/api/v1"
|
|
}
|
|
],
|
|
"tags": [
|
|
{
|
|
"name": "captcha",
|
|
"description": "Operations about captcha"
|
|
}
|
|
],
|
|
"paths": {
|
|
"/captcha": {
|
|
"get": {
|
|
"tags": [
|
|
"captcha"
|
|
],
|
|
"summary": "Captcha generation",
|
|
"description": "",
|
|
"operationId": "captchaGeneration",
|
|
"parameters": [
|
|
{
|
|
"name": "public_token",
|
|
"in": "header",
|
|
"description": "Public token for captcha generation",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "successful operation",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/Captcha"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"403": {
|
|
"description": "Invalid public token value"
|
|
}
|
|
}
|
|
},
|
|
"post": {
|
|
"tags": [
|
|
"captcha"
|
|
],
|
|
"summary": "Checking captcha",
|
|
"description": "",
|
|
"operationId": "captchaChecking",
|
|
"parameters": [
|
|
{
|
|
"name": "public_token",
|
|
"in": "header",
|
|
"description": "Public token for captcha generation",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
],
|
|
"requestBody": {
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/CaptchaChecking"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "successful operation",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/CaptchaVerification"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"403": {
|
|
"description": "Invalid public token value"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/captcha/{captcha_key}": {
|
|
"get": {
|
|
"tags": [
|
|
"captcha"
|
|
],
|
|
"summary": "Verification Information",
|
|
"description": "",
|
|
"operationId": "CaptchaKeyInfo",
|
|
"parameters": [
|
|
{
|
|
"name": "private_token",
|
|
"in": "header",
|
|
"description": "Private token for captcha verification",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
{
|
|
"name": "captcha_key",
|
|
"in": "path",
|
|
"description": "The key that we received when generating the captcha",
|
|
"required": true,
|
|
"schema": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "successful operation",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/CaptchaKeyInfo"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"403": {
|
|
"description": "Invalid private token value"
|
|
},
|
|
"404": {
|
|
"description": "Captcha key not found"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"components": {
|
|
"schemas": {
|
|
"Captcha": {
|
|
"type": "object",
|
|
"properties": {
|
|
"image_base64": {
|
|
"type": "string",
|
|
"format": "byte"
|
|
},
|
|
"image_text_base64": {
|
|
"type": "string",
|
|
"format": "byte"
|
|
},
|
|
"captcha_key": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"image_base64", "image_text_base64", "captcha_key"
|
|
]
|
|
},
|
|
"CaptchaVerification": {
|
|
"type": "object",
|
|
"properties": {
|
|
"status": {
|
|
"type": "boolean"
|
|
},
|
|
"message": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"status", "message"
|
|
]
|
|
},
|
|
"CaptchaChecking": {
|
|
"type": "object",
|
|
"properties": {
|
|
"captcha_key": {
|
|
"type": "string"
|
|
},
|
|
"verification": {
|
|
"type": "array",
|
|
"example": [{"x": 10, "y": 20}, {"x": 30, "y": 30}, {"x": 60, "y": 50}]
|
|
}
|
|
},
|
|
"required": [
|
|
"captcha_key", "verification"
|
|
]
|
|
},
|
|
"CaptchaKeyInfo": {
|
|
"type": "object",
|
|
"properties": {
|
|
"status": {
|
|
"type": "boolean"
|
|
},
|
|
"message": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
"required": [
|
|
"status", "message"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|