Skip to content

Generating the client library

Jon Connolly edited this page Apr 30, 2021 · 4 revisions

The following steps generate the client python library:

  1. run bash script ./generate_swagger.sh
  2. Edit squacapi_client/api_client.py

def __call_api(): method to add the following condition:

if response_data.data.startswith('[') and not response_type.startswith('list['):
            response_type = 'list[' + response_type + ']'

After line 163:

        # perform request and return response
        response_data = self.request(
            method, url, query_params=query_params, headers=header_params,
            post_params=post_params, body=body,
            _preload_content=_preload_content,
            _request_timeout=_request_timeout)

        self.last_response = response_data
        
        if response_data.data.startswith('[') and not response_type.startswith('list['):
            response_type = 'list[' + response_type + ']'

        return_data = response_data

During deserialization of the response object the bulk create for measurements fails since the client thinks it is deserializing a single object and not a collection. By changing the response from:

ReadOnlyMeasurementSerializer

to

list[ReadOnlyMeasurementSerializer]

The return object is properly deserialized into a list of ReadOnlyMeasurementSerializer objects

Clone this wiki locally