labd / commercetools-python-sdk

Commercetools Python SDK
https://commercetools-python-sdk.readthedocs.io/en/latest/
MIT License
17 stars 16 forks source link

updated schemas to use both data_key and attributes #65

Closed mbarga closed 5 years ago

mbarga commented 5 years ago

I found that the serialization of schemas was not working as designed. The calls to schema.dumps() would generate data having keys in snake_case while commercetools backend was expecting json keys in camelCase.

Marshmallow allows the user to set data_key and attributes parameters when defining fields to define the keys to be used for de/serialization. Previously only data_key was used which told the schema what keys to look for when de-serializing, but we also need to pass attributes which defines the key that is used when dumping the json from the schema.

In this PR I simply use the same value passed to data_key and pass it additionally to attributes as well. This was done for all schema definitions in the schemas directory.