From a41f5671b02a4a6a6f31f7192f53b0bb7ca2407b Mon Sep 17 00:00:00 2001
From: Piero Toffanin <pt@masseranolabs.com>
Date: Sat, 11 Sep 2021 16:02:10 -0400
Subject: [PATCH] Add HTML note in README, tweak swagger def

---
 README.md  | 31 ++++++++++++++++++++++++++++++-
 app/app.py |  9 +++++++--
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index daad3d7..2883ab4 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,9 @@ Free and Open Source Machine Translation API, entirely self-hosted. Unlike other
 
 ## API Examples
 
+
+### Plain Text
+
 Request:
 
 ```javascript
@@ -36,6 +39,33 @@ Response:
 }
 ```
 
+### HTML
+
+Request:
+
+```javascript
+const res = await fetch("https://libretranslate.com/translate", {
+	method: "POST",
+	body: JSON.stringify({
+		q: '<a href="#" class="green">Hello!</a>',
+		source: "en",
+		target: "es",
+		format: "html"
+	}),
+	headers: { "Content-Type": "application/json" }
+});
+
+console.log(await res.json());
+```
+
+Response:
+
+```javascript
+{
+    "translatedText": "<a href\"#='class=\"green\"'>¡Hola!</a>"
+}
+```
+
 ## Install and Run
 
 You can run your own API server in just a few lines of setup!
@@ -136,7 +166,6 @@ You can pass application arguments directly to Gunicorn via:
 gunicorn --bind 0.0.0.0:5000 'wsgi:app(api_keys=True)'
 ```
 
-
 ## Manage API Keys
 
 LibreTranslate supports per-user limit quotas, e.g. you can issue API keys to users so that they can enjoy higher requests limits per minute (if you also set `--req-limit`). By default all users are rate-limited based on `--req-limit`, but passing an optional `api_key` parameter to the REST endpoints allows a user to enjoy higher request limits.
diff --git a/app/app.py b/app/app.py
index 19bb846..8576996 100644
--- a/app/app.py
+++ b/app/app.py
@@ -267,9 +267,14 @@ def create_app(args):
             name: format
             schema:
               type: string
-              example: html or text
+              enum: [text, html]
+              default: text
+              example: text
             required: false
-            description: The format of the source text
+            description: >
+              Format of source text:
+               * `text` - Plain text
+               * `html` - HTML markup
           - in: formData
             name: api_key
             schema:
-- 
GitLab