Skip to content

Commit 7cef3e1

Browse files
Merge pull request #12 from Deadpool2000/fix-issue-6
Fix Client.request returning raw strings instead of dicts
2 parents bf149b6 + 58d5178 commit 7cef3e1

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)