I have this model in my drf backend:
class Product:
price_range = ...
I am using EmberData with the JSONApi serializer. I have just found out that JSON API requires dasherized properties. So I need to tell drf:
JSON_API_FORMAT_KEYS = 'dasherize'
And the property gets serialized in the JSON
as:
price-range
Then, EmberData
does its dance, and I get the Ember
model property:
import DS from 'ember-data';
export default DS.Model.extend({
...
priceRange: DS.attr('number'),
...
});
(the old RESTSerializer
was expecting priceRange
in the JSON
, if I recall properly)
So, we go from price_range
-> price-range
-> priceRange
(which is pretty crazy if you ask me). I found all this by trial and error. For drf the corresponding settings are documented here.
Where is this documented for JSONApi
, EmberData
and Ember
? I would like to make sure I have really understood this, and that this is also the case for relationships. The related drf
config setting would be:
JSON_API_FORMAT_RELATION_KEYS = 'dasherize'
Aucun commentaire:
Enregistrer un commentaire