Skip to content

Commit 58d5178

Browse files
committed
�[200~fix: automatically parse double-encoded JSON strings to dicts in Client.request
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~
1 parent bf149b6 commit 58d5178

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

openapi_python_sdk/client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import httpx
55

6+
import json
7+
68
OAUTH_BASE_URL = "https://oauth.openapi.it"
79
TEST_OAUTH_BASE_URL = "https://test.oauth.openapi.it"
810

@@ -62,10 +64,17 @@ def request(
6264
payload = payload or {}
6365
params = params or {}
6466
url = url or ""
65-
return self.client.request(
67+
data = self.client.request(
6668
method=method,
6769
url=url,
6870
headers=self.headers,
6971
json=payload,
7072
params=params,
7173
).json()
74+
75+
if isinstance(data,str):
76+
try:
77+
data=json.loads(data)
78+
except json.JSONDecodeError:
79+
pass
80+
return data

0 commit comments

Comments
 (0)