From 00274aa0acf13b00d1b3ad59731e46b59d7f806d Mon Sep 17 00:00:00 2001
From: Tor-Einar Skog <tor-einar.skog@nibio.no>
Date: Fri, 17 Feb 2023 10:37:27 +0100
Subject: [PATCH] Bugfix: Make endpoints return plain text, not Json

---
 app/main.py | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/app/main.py b/app/main.py
index addd1ed..90e5279 100644
--- a/app/main.py
+++ b/app/main.py
@@ -47,45 +47,45 @@ async def print_model_list(language: str) -> str:
     return _print_model_list(language)
 
 #######  Model metadata endpoints #######
-@app.get("/models/{model_id}/description/{language}", name="Get a model's description")
+@app.get("/models/{model_id}/description/{language}", response_class=PlainTextResponse, name="Get a model's description")
 async def get_model_description(model_id:str, language:str, response:Response):
     return _result_or_404(_get_model_description(model_id, language), model_id, response)
 
-@app.get("/models/{model_id}/description/", name="Get a model's description (default language)")
+@app.get("/models/{model_id}/description/", response_class=PlainTextResponse, name="Get a model's description (default language)")
 async def get_model_description(model_id:str, response:Response):
     return _result_or_404(_get_model_description(model_id, VIPSModel.default_language), model_id, response)
 
-@app.get("/models/{model_id}/name/{language}", name="Get a model's name")
+@app.get("/models/{model_id}/name/{language}", response_class=PlainTextResponse, name="Get a model's name")
 async def get_model_name(model_id: str, language: str, response:Response):
     return _result_or_404(_get_model_name(model_id, language), model_id, response)
 
-@app.get("/models/{model_id}/name/", name="Get a model's name (default language)")
+@app.get("/models/{model_id}/name/", response_class=PlainTextResponse, name="Get a model's name (default language)")
 async def get_model_name(model_id: str, response:Response):
     return _result_or_404(_get_model_name(model_id, VIPSModel.default_language), model_id, response)
 
-@app.get("/models/{model_id}/license/", name="Get a model's license")
+@app.get("/models/{model_id}/license/", response_class=PlainTextResponse, name="Get a model's license")
 async def get_model_license(model_id: str, response:Response):
     requested_model = get_model_instance(model_id)
     return requested_model.license if requested_model is not None else _result_or_404(None, model_id, response)
 
-@app.get("/models/{model_id}/copyright/", name="Get a model's copyright")
+@app.get("/models/{model_id}/copyright/", response_class=PlainTextResponse, name="Get a model's copyright")
 async def get_model_copyright(model_id: str, response:Response):
     requested_model = get_model_instance(model_id)
     return requested_model.copyright if requested_model is not None else _result_or_404(None, model_id, response)
 
-@app.get("/models/{model_id}/warningstatusinterpretation/{language}/", name="How to interpret the warning status (red-yellow-green, what does it mean?) in the specified language (<a href='http://www.loc.gov/standards/iso639-2/php/English_list.php'>ISO-639-2</a>)")
+@app.get("/models/{model_id}/warningstatusinterpretation/{language}/", response_class=PlainTextResponse, name="How to interpret the warning status (red-yellow-green, what does it mean?) in the specified language (<a href='http://www.loc.gov/standards/iso639-2/php/English_list.php'>ISO-639-2</a>)")
 async def get_model_warning_status_interpretation(model_id: str, language: str, response:Response):
     return _result_or_404(_get_model_warning_status_interpretation(model_id, language), model_id, response)
 
-@app.get("/models/{model_id}/warningstatusinterpretation/", name="How to interpret the warning status (red-yellow-green, what does it mean?) (default language)")
+@app.get("/models/{model_id}/warningstatusinterpretation/", response_class=PlainTextResponse, name="How to interpret the warning status (red-yellow-green, what does it mean?) (default language)")
 async def get_model_warning_status_interpretation(model_id: str, response:Response):
     return _result_or_404(_get_model_warning_status_interpretation(model_id, VIPSModel.default_language), model_id, response)
 
-@app.get("/models/{model_id}/usage/{language}/", name="Get a model's usage instructions")
+@app.get("/models/{model_id}/usage/{language}/", response_class=PlainTextResponse, name="Get a model's usage instructions")
 async def get_model_usage(model_id: str, language: str, response:Response):
     return _result_or_404(_get_model_usage(model_id, language), model_id, response)
 
-@app.get("/models/{model_id}/usage/", name="Get a model's usage instructions (default language)")
+@app.get("/models/{model_id}/usage/", response_class=PlainTextResponse, name="Get a model's usage instructions (default language)")
 async def get_model_usage(model_id: str, response:Response):
     return _result_or_404(_get_model_usage(model_id, VIPSModel.default_language), model_id, response)
 
-- 
GitLab