Files
MTranServer/internal/docs/docs.go
2025-12-07 16:49:34 +08:00

1176 lines
38 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs
import "github.com/swaggo/swag"
const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"termsOfService": "https://github.com/xxnuo/MTranServer",
"contact": {
"name": "API Support",
"url": "https://github.com/xxnuo/MTranServer/issues"
},
"license": {
"name": "Apache 2.0",
"url": "https://github.com/xxnuo/MTranServer/blob/main/LICENSE"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/__heartbeat__": {
"get": {
"description": "返回服务状态",
"produces": [
"text/plain"
],
"tags": [
"系统"
],
"summary": "心跳检查",
"responses": {
"200": {
"description": "Ready",
"schema": {
"type": "string"
}
}
}
}
},
"/__lbheartbeat__": {
"get": {
"description": "返回负载均衡器心跳状态",
"produces": [
"text/plain"
],
"tags": [
"系统"
],
"summary": "负载均衡心跳检查",
"responses": {
"200": {
"description": "Ready",
"schema": {
"type": "string"
}
}
}
}
},
"/deepl": {
"post": {
"description": "兼容 DeepL API v2 的翻译接口",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"插件"
],
"summary": "DeepL 翻译兼容接口",
"parameters": [
{
"type": "string",
"description": "API Token",
"name": "token",
"in": "query"
},
{
"description": "DeepL 翻译请求",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.DeeplTranslateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.DeeplTranslateResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/google/language/translate/v2": {
"post": {
"description": "兼容 Google Translate API v2 的翻译接口",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"插件"
],
"summary": "Google 翻译兼容接口",
"parameters": [
{
"type": "string",
"description": "API Key",
"name": "key",
"in": "query"
},
{
"description": "Google 翻译请求",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.GoogleTranslateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.GoogleTranslateResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/google/translate_a/single": {
"get": {
"description": "兼容 Google translate_a/single 的翻译接口",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"插件"
],
"summary": "Google translate_a/single 兼容接口",
"parameters": [
{
"type": "string",
"default": "gtx",
"description": "客户端类型",
"name": "client",
"in": "query"
},
{
"type": "string",
"example": "en",
"description": "源语言代码",
"name": "sl",
"in": "query",
"required": true
},
{
"type": "string",
"example": "zh-CN",
"description": "目标语言代码",
"name": "tl",
"in": "query",
"required": true
},
{
"type": "string",
"default": "t",
"description": "数据类型",
"name": "dt",
"in": "query"
},
{
"type": "string",
"example": "Hello, world!",
"description": "待翻译文本",
"name": "q",
"in": "query",
"required": true
},
{
"type": "string",
"description": "API Key",
"name": "key",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {}
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/hcfy": {
"post": {
"description": "兼容划词翻译自定义翻译源接口",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"插件"
],
"summary": "划词翻译兼容接口",
"parameters": [
{
"type": "string",
"description": "API Token",
"name": "token",
"in": "query"
},
{
"description": "划词翻译请求",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.HcfyTranslateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.HcfyTranslateResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/health": {
"get": {
"description": "检查服务是否正常运行",
"produces": [
"application/json"
],
"tags": [
"系统"
],
"summary": "健康检查",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/imme": {
"post": {
"description": "为沉浸式翻译插件提供的翻译接口",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"插件"
],
"summary": "沉浸式翻译插件接口",
"parameters": [
{
"type": "string",
"description": "API Token",
"name": "token",
"in": "query"
},
{
"description": "沉浸式翻译请求",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.ImmeTranslateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.ImmeTranslateResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/kiss": {
"post": {
"description": "为简约翻译插件提供的单文本翻译接口",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"插件"
],
"summary": "简约翻译插件接口(非聚合)",
"parameters": [
{
"type": "string",
"description": "API Token",
"name": "KEY",
"in": "header"
},
{
"description": "简约翻译请求",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.KissTranslateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.KissTranslateResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/languages": {
"get": {
"security": [
{
"ApiKeyAuth": []
},
{
"ApiKeyQuery": []
}
],
"description": "返回所有支持的翻译语言代码",
"produces": [
"application/json"
],
"tags": [
"翻译"
],
"summary": "获取支持的语言列表",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/translate": {
"post": {
"security": [
{
"ApiKeyAuth": []
},
{
"ApiKeyQuery": []
}
],
"description": "翻译单个文本",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"翻译"
],
"summary": "单文本翻译",
"parameters": [
{
"description": "翻译请求",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.TranslateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.TranslateResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/translate/batch": {
"post": {
"security": [
{
"ApiKeyAuth": []
},
{
"ApiKeyQuery": []
}
],
"description": "批量翻译多个文本",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"翻译"
],
"summary": "批量翻译",
"parameters": [
{
"description": "批量翻译请求",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.TranslateBatchRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.TranslateBatchResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
},
"/version": {
"get": {
"description": "返回当前服务的版本号",
"produces": [
"application/json"
],
"tags": [
"系统"
],
"summary": "获取服务版本",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
}
}
}
},
"definitions": {
"handlers.DeeplTranslateRequest": {
"type": "object",
"required": [
"target_lang",
"text"
],
"properties": {
"context": {
"type": "string"
},
"enable_beta_languages": {
"type": "boolean"
},
"formality": {
"type": "string",
"example": "default"
},
"glossary_id": {
"type": "string"
},
"ignore_tags": {
"type": "array",
"items": {
"type": "string"
}
},
"model_type": {
"type": "string",
"example": "quality_optimized"
},
"non_splitting_tags": {
"type": "array",
"items": {
"type": "string"
}
},
"outline_detection": {
"type": "string",
"example": "1"
},
"preserve_formatting": {
"type": "string",
"example": "0"
},
"source_lang": {
"type": "string",
"example": "EN"
},
"split_sentences": {
"type": "string",
"example": "1"
},
"splitting_tags": {
"type": "array",
"items": {
"type": "string"
}
},
"tag_handling": {
"type": "string",
"example": "xml"
},
"target_lang": {
"type": "string",
"example": "DE"
},
"text": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"Hello",
" world!"
]
}
}
},
"handlers.DeeplTranslateResponse": {
"type": "object",
"properties": {
"translations": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.DeeplTranslation"
}
}
}
},
"handlers.DeeplTranslation": {
"type": "object",
"properties": {
"detected_source_language": {
"type": "string",
"example": "EN"
},
"text": {
"type": "string",
"example": "Hallo, Welt!"
}
}
},
"handlers.GoogleTranslateRequest": {
"type": "object",
"required": [
"q",
"source",
"target"
],
"properties": {
"format": {
"type": "string",
"example": "text"
},
"q": {
"type": "string",
"example": "The Great Pyramid of Giza"
},
"source": {
"type": "string",
"example": "en"
},
"target": {
"type": "string",
"example": "zh-Hans"
}
}
},
"handlers.GoogleTranslateResponse": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"translations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"translatedText": {
"type": "string",
"example": "吉萨大金字塔"
}
}
}
}
}
}
}
},
"handlers.HcfyDict": {
"type": "object",
"properties": {
"pos": {
"type": "string",
"example": "n."
},
"terms": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"你好",
"问候"
]
}
}
},
"handlers.HcfyPhonetic": {
"type": "object",
"properties": {
"name": {
"type": "string",
"example": "美"
},
"ttsURI": {
"type": "string",
"example": "https://..."
},
"value": {
"type": "string",
"example": "həˈloʊ"
}
}
},
"handlers.HcfyTranslateRequest": {
"type": "object",
"required": [
"destination",
"name",
"text"
],
"properties": {
"destination": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"中文(简体)",
"英语"
]
},
"name": {
"type": "string",
"example": "翻译一"
},
"source": {
"type": "string",
"example": "英语"
},
"text": {
"type": "string",
"example": "Hello, word translation."
}
}
},
"handlers.HcfyTranslateResponse": {
"type": "object",
"properties": {
"dict": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.HcfyDict"
}
},
"from": {
"type": "string",
"example": "英语"
},
"link": {
"type": "string",
"example": "https://..."
},
"phonetic": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.HcfyPhonetic"
}
},
"result": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"你好,划词翻译。"
]
},
"text": {
"type": "string",
"example": "Hello, word translation."
},
"to": {
"type": "string",
"example": "中文(简体)"
},
"ttsURI": {
"type": "string",
"example": "https://..."
}
}
},
"handlers.ImmeTranslateRequest": {
"type": "object",
"required": [
"source_lang",
"target_lang",
"text_list"
],
"properties": {
"source_lang": {
"type": "string",
"example": "en"
},
"target_lang": {
"type": "string",
"example": "zh-CN"
},
"text_list": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"Hello",
" world!",
"Good morning!"
]
}
}
},
"handlers.ImmeTranslateResponse": {
"type": "object",
"properties": {
"translations": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ImmeTranslation"
}
}
}
},
"handlers.ImmeTranslation": {
"type": "object",
"properties": {
"detected_source_lang": {
"type": "string",
"example": "en"
},
"text": {
"type": "string",
"example": "你好,世界!"
}
}
},
"handlers.KissTranslateRequest": {
"type": "object",
"required": [
"from",
"text",
"to"
],
"properties": {
"from": {
"type": "string",
"example": "en"
},
"text": {
"type": "string",
"example": "Hello, world!"
},
"to": {
"type": "string",
"example": "zh-CN"
}
}
},
"handlers.KissTranslateResponse": {
"type": "object",
"properties": {
"src": {
"type": "string",
"example": "en"
},
"text": {
"type": "string",
"example": "你好,世界!"
}
}
},
"handlers.TranslateBatchRequest": {
"type": "object",
"required": [
"from",
"texts",
"to"
],
"properties": {
"from": {
"type": "string",
"example": "en"
},
"html": {
"type": "boolean",
"example": false
},
"texts": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"Hello",
" world!",
"Good morning!"
]
},
"to": {
"type": "string",
"example": "zh-Hans"
}
}
},
"handlers.TranslateBatchResponse": {
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"你好,世界!",
"早上好!"
]
}
}
},
"handlers.TranslateRequest": {
"type": "object",
"required": [
"from",
"text",
"to"
],
"properties": {
"from": {
"type": "string",
"example": "en"
},
"html": {
"type": "boolean",
"example": false
},
"text": {
"type": "string",
"example": "Hello, world!"
},
"to": {
"type": "string",
"example": "zh-Hans"
}
}
},
"handlers.TranslateResponse": {
"type": "object",
"properties": {
"result": {
"type": "string",
"example": "你好,世界!"
}
}
}
},
"securityDefinitions": {
"ApiKeyAuth": {
"type": "apiKey",
"name": "Authorization",
"in": "header"
},
"ApiKeyQuery": {
"type": "apiKey",
"name": "token",
"in": "query"
}
}
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "3.0.0",
Host: "localhost:8989",
BasePath: "/",
Schemes: []string{},
Title: "MTranServer API",
Description: "超低资源消耗超快的离线翻译服务器 API",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}
func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}