flask-rest-jsonapi icon indicating copy to clipboard operation
flask-rest-jsonapi copied to clipboard

mismatch with JSON:api specification

Open gdgupta11 opened this issue 7 years ago • 2 comments
trafficstars

As per JSON:api specification the the attributes like first-name should be dashed ( - ) but in the example here http://flask-rest-jsonapi.readthedocs.io/en/stable/ first_name ( with underscore ) is used.

This is creating problem for me when I am using with ember.js because in ember.js the JSONAPISerializer expects attributes to be dasherized in the document payload returned by your server.

When I am trying to do that in my Flask model as well as schema for Flask-rest-jsonapi, it says me that SyntaxError: can't assign to operator.

gdgupta11 avatar Feb 13 '18 18:02 gdgupta11

I think this is a issue with the serializer, marshmallow.

hellupline avatar Mar 01 '18 14:03 hellupline

@gdgupta11 You can setup an inflection on your schema to handle dash conversion in field names: https://marshmallow-jsonapi.readthedocs.io/en/latest/quickstart.html#inflection

This is how I've implemented that: https://github.com/rgant/saas-api-boilerplate/blob/master/ourmarshmallow/schema.py#L57

rgant avatar Mar 01 '18 14:03 rgant