diff --git a/openapi_python_client/parser/openapi.py b/openapi_python_client/parser/openapi.py index 387076a71..8ebf02a39 100644 --- a/openapi_python_client/parser/openapi.py +++ b/openapi_python_client/parser/openapi.py @@ -274,10 +274,11 @@ def _add_responses( status_code=status_code, data=response_data, schemas=schemas, parent_name=endpoint.name, config=config ) if isinstance(response, ParseError): + detail_suffix = "" if response.detail is None else f" ({response.detail})" endpoint.errors.append( ParseError( detail=( - f"Cannot parse response for status code {status_code}, " + f"Cannot parse response for status code {status_code}{detail_suffix}, " f"response will be ommitted from generated client" ), data=response.data, diff --git a/tests/test_parser/test_openapi.py b/tests/test_parser/test_openapi.py index 0c1cd509f..d2bb448e0 100644 --- a/tests/test_parser/test_openapi.py +++ b/tests/test_parser/test_openapi.py @@ -460,7 +460,7 @@ def test__add_responses_error(self, mocker): "404": response_2_data, } endpoint = self.make_endpoint() - parse_error = ParseError(data=mocker.MagicMock()) + parse_error = ParseError(data=mocker.MagicMock(), detail="some problem") response_from_data = mocker.patch(f"{MODULE_NAME}.response_from_data", return_value=(parse_error, schemas)) config = MagicMock() @@ -474,11 +474,13 @@ def test__add_responses_error(self, mocker): ) assert response.errors == [ ParseError( - detail=f"Cannot parse response for status code 200, response will be ommitted from generated client", + detail=f"Cannot parse response for status code 200 (some problem), " + "response will be ommitted from generated client", data=parse_error.data, ), ParseError( - detail=f"Cannot parse response for status code 404, response will be ommitted from generated client", + detail=f"Cannot parse response for status code 404 (some problem), " + "response will be ommitted from generated client", data=parse_error.data, ), ]