aboutsummaryrefslogtreecommitdiffstats
path: root/fatcat_scholar/api_entities.py
diff options
context:
space:
mode:
Diffstat (limited to 'fatcat_scholar/api_entities.py')
-rw-r--r--fatcat_scholar/api_entities.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/fatcat_scholar/api_entities.py b/fatcat_scholar/api_entities.py
index 53455e8..738c5c8 100644
--- a/fatcat_scholar/api_entities.py
+++ b/fatcat_scholar/api_entities.py
@@ -3,6 +3,8 @@ import json
import collections
from fatcat_openapi_client import ApiClient
+_global_serde_api_client = ApiClient()
+
def entity_to_dict(entity, api_client=None):
"""
Hack to take advantage of the code-generated serialization code.
@@ -14,7 +16,7 @@ def entity_to_dict(entity, api_client=None):
that this argument may become mandatory.
"""
if not api_client:
- api_client = ApiClient()
+ api_client = _global_serde_api_client
return api_client.sanitize_for_serialization(entity)
def entity_from_json(json_str, entity_type, api_client=None):
@@ -24,7 +26,7 @@ def entity_from_json(json_str, entity_type, api_client=None):
See note on `entity_to_dict()` about api_client argument.
"""
if not api_client:
- api_client = ApiClient()
+ api_client = _global_serde_api_client
thing = collections.namedtuple('Thing', ['data'])
thing.data = json_str
return api_client.deserialize(thing, entity_type)