From 87a38160f0460b54a3e304271aa9884a613217be Mon Sep 17 00:00:00 2001
From: Elton Chou <plscd748@gmail.com>
Date: Tue, 20 Sep 2022 04:44:54 +0800
Subject: [PATCH 1/2] fix error message formatting

---
 .../main/resources/python-experimental/api_client.handlebars    | 2 +-
 .../python-experimental/unit_test_api/api_client.py             | 2 +-
 .../petstore/python-experimental/petstore_api/api_client.py     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/python-experimental/api_client.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/api_client.handlebars
index 96fe2849057..527d5bbd243 100644
--- a/modules/openapi-generator/src/main/resources/python-experimental/api_client.handlebars
+++ b/modules/openapi-generator/src/main/resources/python-experimental/api_client.handlebars
@@ -916,7 +916,7 @@ class OpenApiResponse(JSONDetector):
             if content_type not in self.content:
                 raise ApiValueError(
                     f'Invalid content_type={content_type} returned for response with '
-                    'status_code={str(response.status)}'
+                    f'status_code={str(response.status)}'
                 )
             body_schema = self.content[content_type].schema
             if body_schema is None:
diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py
index 22431807bde..daedbc6c229 100644
--- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py
+++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py
@@ -920,7 +920,7 @@ class OpenApiResponse(JSONDetector):
             if content_type not in self.content:
                 raise ApiValueError(
                     f'Invalid content_type={content_type} returned for response with '
-                    'status_code={str(response.status)}'
+                    f'status_code={str(response.status)}'
                 )
             body_schema = self.content[content_type].schema
             if body_schema is None:
diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/api_client.py
index 36996d1ead4..e49de5663ba 100644
--- a/samples/openapi3/client/petstore/python-experimental/petstore_api/api_client.py
+++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/api_client.py
@@ -920,7 +920,7 @@ class OpenApiResponse(JSONDetector):
             if content_type not in self.content:
                 raise ApiValueError(
                     f'Invalid content_type={content_type} returned for response with '
-                    'status_code={str(response.status)}'
+                    f'status_code={str(response.status)}'
                 )
             body_schema = self.content[content_type].schema
             if body_schema is None:
-- 
GitLab


From 27a0c8597c0f389d3d78db5ce076b4d759cc21e8 Mon Sep 17 00:00:00 2001
From: Elton Chou <plscd748@gmail.com>
Date: Tue, 20 Sep 2022 05:01:33 +0800
Subject: [PATCH 2/2] add more infos in error message

---
 .../main/resources/python-experimental/api_client.handlebars  | 4 ++--
 .../python-experimental/unit_test_api/api_client.py           | 4 ++--
 .../petstore/python-experimental/petstore_api/api_client.py   | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/modules/openapi-generator/src/main/resources/python-experimental/api_client.handlebars b/modules/openapi-generator/src/main/resources/python-experimental/api_client.handlebars
index 527d5bbd243..cbbc9418486 100644
--- a/modules/openapi-generator/src/main/resources/python-experimental/api_client.handlebars
+++ b/modules/openapi-generator/src/main/resources/python-experimental/api_client.handlebars
@@ -915,8 +915,8 @@ class OpenApiResponse(JSONDetector):
         if self.content is not None:
             if content_type not in self.content:
                 raise ApiValueError(
-                    f'Invalid content_type={content_type} returned for response with '
-                    f'status_code={str(response.status)}'
+                    f"Invalid content_type returned. Content_type='{content_type}' was returned "
+                    f"when only {str(set(self.content))} are defined for status_code={str(response.status)}"
                 )
             body_schema = self.content[content_type].schema
             if body_schema is None:
diff --git a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py
index daedbc6c229..a66844ae6e6 100644
--- a/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py
+++ b/samples/openapi3/client/3_0_3_unit_test/python-experimental/unit_test_api/api_client.py
@@ -919,8 +919,8 @@ class OpenApiResponse(JSONDetector):
         if self.content is not None:
             if content_type not in self.content:
                 raise ApiValueError(
-                    f'Invalid content_type={content_type} returned for response with '
-                    f'status_code={str(response.status)}'
+                    f"Invalid content_type returned. Content_type='{content_type}' was returned "
+                    f"when only {str(set(self.content))} are defined for status_code={str(response.status)}"
                 )
             body_schema = self.content[content_type].schema
             if body_schema is None:
diff --git a/samples/openapi3/client/petstore/python-experimental/petstore_api/api_client.py b/samples/openapi3/client/petstore/python-experimental/petstore_api/api_client.py
index e49de5663ba..7f70052b8a9 100644
--- a/samples/openapi3/client/petstore/python-experimental/petstore_api/api_client.py
+++ b/samples/openapi3/client/petstore/python-experimental/petstore_api/api_client.py
@@ -919,8 +919,8 @@ class OpenApiResponse(JSONDetector):
         if self.content is not None:
             if content_type not in self.content:
                 raise ApiValueError(
-                    f'Invalid content_type={content_type} returned for response with '
-                    f'status_code={str(response.status)}'
+                    f"Invalid content_type returned. Content_type='{content_type}' was returned "
+                    f"when only {str(set(self.content))} are defined for status_code={str(response.status)}"
                 )
             body_schema = self.content[content_type].schema
             if body_schema is None:
-- 
GitLab