diff --git a/docs/TransactionsApi.md b/docs/TransactionsApi.md index 30603f1..74bdf7d 100644 --- a/docs/TransactionsApi.md +++ b/docs/TransactionsApi.md @@ -947,7 +947,7 @@ Name | Type | Description | Notes | Status code | Description | Response headers | |-------------|-------------|------------------| -**209** | The transactions were successfully updated | - | +**200** | The transactions were successfully updated | - | **400** | The request could not be understood due to malformed syntax or validation error(s). | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/open_api_spec.yaml b/open_api_spec.yaml index ad3951b..4d4633d 100644 --- a/open_api_spec.yaml +++ b/open_api_spec.yaml @@ -1189,7 +1189,7 @@ paths: $ref: "#/components/schemas/PatchTransactionsWrapper" required: true responses: - "209": + "200": description: The transactions were successfully updated content: application/json: diff --git a/tests/test_response_deserialize.py b/tests/test_response_deserialize.py index 703301e..2b23642 100644 --- a/tests/test_response_deserialize.py +++ b/tests/test_response_deserialize.py @@ -1,6 +1,8 @@ import json -from unittest.mock import MagicMock +from unittest.mock import MagicMock, patch +import ynab +from ynab.api.transactions_api import TransactionsApi from ynab.api_client import ApiClient from ynab.rest import RESTResponse @@ -35,3 +37,40 @@ def test_deserialize_user_response(): assert result.status_code == 200 assert str(result.data.data.user.id) == "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" + + +def test_update_transactions_with_http_info_deserializes_real_200_response(): + """Regression test: TransactionsApi.update_transactions must map status + 200, not 209, in its own generated _response_types_map. + + The spec previously declared updateTransactions' success response as + HTTP 209, but the real API returns 200. Since 200 didn't match the + hardcoded map inside update_transactions/_with_http_info/ + _without_preload_content, every real, successful call silently + deserialized to data=None -- callers had no way to tell the request + had in fact succeeded. This calls the real generated method (not a + hand-supplied response_types_map) so it actually exercises the fixed + value embedded in transactions_api.py. + """ + client = ApiClient() + rest_resp = make_rest_response(200, { + "data": { + "transaction_ids": ["aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"], + "transactions": [], + "duplicate_import_ids": [], + "server_knowledge": 1, + } + }) + + with patch.object(ApiClient, "call_api", return_value=rest_resp): + api = TransactionsApi(client) + result = api.update_transactions_with_http_info( + plan_id="last-used", + data=ynab.PatchTransactionsWrapper(transactions=[]), + ) + + assert result.status_code == 200 + assert result.data is not None + assert result.data.data.transaction_ids == [ + "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" + ] diff --git a/ynab/api/transactions_api.py b/ynab/api/transactions_api.py index 8b055ca..bfe497a 100644 --- a/ynab/api/transactions_api.py +++ b/ynab/api/transactions_api.py @@ -3344,7 +3344,7 @@ def update_transactions( ) _response_types_map: Dict[str, Optional[str]] = { - '209': "SaveTransactionsResponse", + '200': "SaveTransactionsResponse", '400': "ErrorResponse", } response_data = self.api_client.call_api( @@ -3416,7 +3416,7 @@ def update_transactions_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '209': "SaveTransactionsResponse", + '200': "SaveTransactionsResponse", '400': "ErrorResponse", } response_data = self.api_client.call_api( @@ -3488,7 +3488,7 @@ def update_transactions_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '209': "SaveTransactionsResponse", + '200': "SaveTransactionsResponse", '400': "ErrorResponse", } response_data = self.api_client.call_api(