From e8a0ce3890c60d92548bedf44c82c00df0777235 Mon Sep 17 00:00:00 2001 From: Frankie Dintino Date: Fri, 21 Jul 2023 11:26:48 -0400 Subject: [PATCH] fix: Use source "response.text" for any mime-type starting with text/ Responses with "Content-Type: text/csv" or "Content-Type: text/xml" ought to be treated the same as text/html --- openapi_python_client/parser/responses.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openapi_python_client/parser/responses.py b/openapi_python_client/parser/responses.py index e1f2cb49a..56510c545 100644 --- a/openapi_python_client/parser/responses.py +++ b/openapi_python_client/parser/responses.py @@ -22,10 +22,11 @@ class Response: def _source_by_content_type(content_type: str) -> Optional[str]: + if content_type.startswith("text/"): + return "response.text" known_content_types = { "application/json": "response.json()", "application/octet-stream": "response.content", - "text/html": "response.text", } source = known_content_types.get(content_type) if source is None and content_type.endswith("+json"):