Hello all,
First of all, I’m mostly focused on python here, so I didn’t check other languages.
I kinda shocked that there’s no example of implementation of a caching mechanism on the client side for the ESI, using swagger_client. So to be nice on ESI servers (and my own) I’ve started this quest and ended up with this (cache actually not in the example code for the sake of simplicity):
import swagger_client as esi_client
class RESTClientObjectCached(esi_client.rest.RESTClientObject):
def __init__(self, pools_size=4):
super().__init__(pools_size=pools_size)
def request(self, method, url, query_params=None, headers=None,
body=None, post_params=None):
logger.debug('Cached request')
r = super().request(method=method, url=url, query_params=query_params,
headers=headers, body=body, post_params=post_params)
return r
class ApiClientCached(esi_client.ApiClient):
def __init__(self, host=None, header_name=None, header_value=None, cookie=None):
super().__init__(host=host, header_name=header_name, header_value=header_value, cookie=cookie)
self.rest_client = RESTClientObjectCached()
Which works, but I must admit that I didn’t like having to copy&paste function signatures (so I still have some sort of validation in my IDE). I will work with the diskcache python module and consider posting here my progress.
On the meanwhile (I’m not a pro in the swagger specs, so correct me if I’m wrong), wouldn’t be nicer if the ApiClient class constructor would be like:
def __init__(self, rest_client=RESTClientObject(), host=None, header_name=None, header_value=None, cookie=None)
Is it possible to use swagger-codegen for this or is it something that (if CCP willing to) needs to be changed in the spec?
Cheers