Hello All,
We are using the Python SDK to query some of the APIs and store the responses in Google BigQuery and having some problems using the response schema matching the API response.
We can see that all the APIs responses' schemas are documented under each API method --> API Responses --> 200 successful operation, both with the Schema definition and and a JSON example response.
For example, see: POST /api/v2/analytics/conversations/details/query .
We also got hold of the Swagger Schema definition file
We have two problems:
1 - We need an API response schema definition with fields' names and types to be able to create the target BigQuery table. We also need the response schema to schema-validate incoming payloads before storing them in our tables.
A JSON example response (like the one we find in the documentation, left side in the pic) could also work, since we could use BigQuery schema generator tools to create the target BigQuery schema.
The API response schema OR the JSON example response need to match the field's names and types of the json payload we receive from the Python SDK.
Problem: The Schemas in the documentation and in the Swagger Schema definition file, as well as the JSON example response in the online docs are CamelCase while the response from the Python SDK comes as snake_case. Thus, the fields are not named the same (see pic).
2 - The JSON example response (very useful to autogenerate a schema for almost any database) does not differ all the atomic data types, for example, the numeric fields (both float and integers) are represented with a 0, zero digit. Same for the timestamps fields which are represented as a string (conversationEnd, conversationStart), giving little option to infer the type correctly.
Problem : we cannot programmatically generate the correct field types for all the fields.
We can manually read the docs and try to figure out the specific types of the ambiguous fields, but it proves hard with so many fields
We are looking at some workarounds, like creating the schemas we need from the Swagger Schema definition file (A: dereference the objects we need, b: do a CamelCase to snake_case conversion and C: apply some kind of JSON-Schema to BigQuery schema transformer) but do you know if there's any easy way to get hold of the actual response schema used by the Python SDK responses ?
Thank you