Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion openapi_python_client/parser/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions tests/test_parser/test_openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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,
),
]
Expand Down