diff --git a/openapi_python_client/openapi_parser/responses.py b/openapi_python_client/openapi_parser/responses.py index c00cca8ea..f9f373ea3 100644 --- a/openapi_python_client/openapi_parser/responses.py +++ b/openapi_python_client/openapi_parser/responses.py @@ -80,7 +80,7 @@ def constructor(self) -> str: def response_from_dict(*, status_code: int, data: Dict[str, Any]) -> Response: """ Generate a Response from the OpenAPI dictionary representation of it """ if "content" not in data: - raise ParseError(data) + return Response(status_code=status_code) content = data["content"] if "application/json" in content: diff --git a/tests/test_openapi_parser/test_responses.py b/tests/test_openapi_parser/test_responses.py index 41fc0452b..0dc4f3e44 100644 --- a/tests/test_openapi_parser/test_responses.py +++ b/tests/test_openapi_parser/test_responses.py @@ -95,11 +95,16 @@ def test_constructor(self): class TestResponseFromDict: - def test_response_from_dict_no_content(self): + def test_response_from_dict_no_content(self, mocker): from openapi_python_client.openapi_parser.responses import response_from_dict - with pytest.raises(ValueError): - response_from_dict(status_code=200, data={}) + Response = mocker.patch(f"{MODULE_NAME}.Response") + + status_code = mocker.MagicMock(autospec=int) + response = response_from_dict(status_code=status_code, data={}) + + Response.assert_called_once_with(status_code=status_code) + assert response == Response() def test_response_from_dict_unsupported_content_type(self): from openapi_python_client.openapi_parser.responses import response_from_dict