mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2025-07-31 14:33:51 -04:00
Merge pull request #823 from pierotofy/swaggerup
Improve swagger definitions
This commit is contained in:
commit
ee32eea614
@ -490,18 +490,19 @@ def create_app(args):
|
|||||||
@limiter.exempt
|
@limiter.exempt
|
||||||
def langs():
|
def langs():
|
||||||
"""
|
"""
|
||||||
Retrieve list of supported languages
|
Get Supported Languages
|
||||||
---
|
---
|
||||||
tags:
|
tags:
|
||||||
- translate
|
- translate
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: List of languages
|
description: List of supported languages
|
||||||
schema:
|
schema:
|
||||||
id: languages
|
id: languages
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: object
|
type: object
|
||||||
|
description: Supported language
|
||||||
properties:
|
properties:
|
||||||
code:
|
code:
|
||||||
type: string
|
type: string
|
||||||
@ -537,7 +538,7 @@ def create_app(args):
|
|||||||
@access_check
|
@access_check
|
||||||
def translate():
|
def translate():
|
||||||
"""
|
"""
|
||||||
Translate text from a language to another
|
Translate Text
|
||||||
---
|
---
|
||||||
tags:
|
tags:
|
||||||
- translate
|
- translate
|
||||||
@ -558,7 +559,7 @@ def create_app(args):
|
|||||||
type: string
|
type: string
|
||||||
example: en
|
example: en
|
||||||
required: true
|
required: true
|
||||||
description: Source language code
|
description: Source language code or "auto" for auto detection
|
||||||
- in: formData
|
- in: formData
|
||||||
name: target
|
name: target
|
||||||
schema:
|
schema:
|
||||||
@ -595,7 +596,7 @@ def create_app(args):
|
|||||||
description: API key
|
description: API key
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: Translated text
|
description: Translation
|
||||||
schema:
|
schema:
|
||||||
id: translate
|
id: translate
|
||||||
type: object
|
type: object
|
||||||
@ -605,6 +606,47 @@ def create_app(args):
|
|||||||
- type: string
|
- type: string
|
||||||
- type: array
|
- type: array
|
||||||
description: Translated text(s)
|
description: Translated text(s)
|
||||||
|
detectedLanguage:
|
||||||
|
oneOf:
|
||||||
|
- type: object
|
||||||
|
properties:
|
||||||
|
confidence:
|
||||||
|
type: number
|
||||||
|
format: float
|
||||||
|
minimum: 0
|
||||||
|
maximum: 100
|
||||||
|
description: Confidence value
|
||||||
|
example: 100
|
||||||
|
language:
|
||||||
|
type: string
|
||||||
|
description: Language code
|
||||||
|
- type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
confidence:
|
||||||
|
type: number
|
||||||
|
format: float
|
||||||
|
minimum: 0
|
||||||
|
maximum: 100
|
||||||
|
description: Confidence value
|
||||||
|
example: 100
|
||||||
|
language:
|
||||||
|
type: string
|
||||||
|
description: Language code
|
||||||
|
alternatives:
|
||||||
|
oneOf:
|
||||||
|
- type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
- type: array
|
||||||
|
items:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
description: Alternative translations
|
||||||
|
required:
|
||||||
|
- translatedText
|
||||||
400:
|
400:
|
||||||
description: Invalid request
|
description: Invalid request
|
||||||
schema:
|
schema:
|
||||||
@ -793,7 +835,7 @@ def create_app(args):
|
|||||||
@access_check
|
@access_check
|
||||||
def translate_file():
|
def translate_file():
|
||||||
"""
|
"""
|
||||||
Translate file from a language to another
|
Translate a File
|
||||||
---
|
---
|
||||||
tags:
|
tags:
|
||||||
- translate
|
- translate
|
||||||
@ -811,7 +853,7 @@ def create_app(args):
|
|||||||
type: string
|
type: string
|
||||||
example: en
|
example: en
|
||||||
required: true
|
required: true
|
||||||
description: Source language code
|
description: Source language code or "auto" for auto detection
|
||||||
- in: formData
|
- in: formData
|
||||||
name: target
|
name: target
|
||||||
schema:
|
schema:
|
||||||
@ -968,7 +1010,7 @@ def create_app(args):
|
|||||||
@access_check
|
@access_check
|
||||||
def detect():
|
def detect():
|
||||||
"""
|
"""
|
||||||
Detect the language of a single text
|
Detect Language of Text
|
||||||
---
|
---
|
||||||
tags:
|
tags:
|
||||||
- translate
|
- translate
|
||||||
@ -998,7 +1040,7 @@ def create_app(args):
|
|||||||
properties:
|
properties:
|
||||||
confidence:
|
confidence:
|
||||||
type: number
|
type: number
|
||||||
format: integer
|
format: float
|
||||||
minimum: 0
|
minimum: 0
|
||||||
maximum: 100
|
maximum: 100
|
||||||
description: Confidence value
|
description: Confidence value
|
||||||
@ -1059,10 +1101,10 @@ def create_app(args):
|
|||||||
@limiter.exempt
|
@limiter.exempt
|
||||||
def frontend_settings():
|
def frontend_settings():
|
||||||
"""
|
"""
|
||||||
Retrieve frontend specific settings
|
Retrieve Frontend Settings
|
||||||
---
|
---
|
||||||
tags:
|
tags:
|
||||||
- frontend
|
- misc
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: frontend settings
|
description: frontend settings
|
||||||
@ -1139,10 +1181,10 @@ def create_app(args):
|
|||||||
@bp.post("/suggest")
|
@bp.post("/suggest")
|
||||||
def suggest():
|
def suggest():
|
||||||
"""
|
"""
|
||||||
Submit a suggestion to improve a translation
|
Submit a Suggestion to Improve a Translation
|
||||||
---
|
---
|
||||||
tags:
|
tags:
|
||||||
- feedback
|
- misc
|
||||||
parameters:
|
parameters:
|
||||||
- in: formData
|
- in: formData
|
||||||
name: q
|
name: q
|
||||||
@ -1238,6 +1280,8 @@ def create_app(args):
|
|||||||
swag = swagger(app)
|
swag = swagger(app)
|
||||||
swag["info"]["version"] = get_version()
|
swag["info"]["version"] = get_version()
|
||||||
swag["info"]["title"] = "LibreTranslate"
|
swag["info"]["title"] = "LibreTranslate"
|
||||||
|
swag["info"]["description"] = "Free and Open Source Machine Translation API."
|
||||||
|
swag["info"]["license"] = {"name": "AGPL-3.0"}
|
||||||
|
|
||||||
@app.route(api_url)
|
@app.route(api_url)
|
||||||
@limiter.exempt
|
@limiter.exempt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user