miLibris / flask-rest-jsonapi

Flask extension to build REST APIs around JSONAPI 1.0 specification.
http://flask-rest-jsonapi.readthedocs.io
MIT License
598 stars 153 forks source link

mismatch with JSON:api specification #88

Open gdgupta11 opened 6 years ago

gdgupta11 commented 6 years ago

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.

hellupline commented 6 years ago

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

rgant commented 6 years ago

@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