From 58d517875282e6ce8dfe39c53f9cbb4efef994a3 Mon Sep 17 00:00:00 2001 From: Deadpool2000 Date: Wed, 18 Mar 2026 22:14:20 +0530 Subject: [PATCH] =?UTF-8?q?=1B[200~fix:=20automatically=20parse=20double-e?= =?UTF-8?q?ncoded=20JSON=20strings=20to=20dicts=20in=20Client.request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: decode raw JSON strings to dictionaries in client.request() to remove Flask boilerplate fix: natively decode stringified API responses into JSON dicts within the SDK~ --- openapi_python_sdk/client.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/openapi_python_sdk/client.py b/openapi_python_sdk/client.py index 04c5a31..4268bda 100644 --- a/openapi_python_sdk/client.py +++ b/openapi_python_sdk/client.py @@ -3,6 +3,8 @@ import httpx +import json + OAUTH_BASE_URL = "https://oauth.openapi.it" TEST_OAUTH_BASE_URL = "https://test.oauth.openapi.it" @@ -62,10 +64,17 @@ def request( payload = payload or {} params = params or {} url = url or "" - return self.client.request( + data = self.client.request( method=method, url=url, headers=self.headers, json=payload, params=params, ).json() + + if isinstance(data,str): + try: + data=json.loads(data) + except json.JSONDecodeError: + pass + return data \ No newline at end of file