Skip to content

Commit cfccdf8

Browse files
committed
update imports in the minimal api example
1 parent c7a5340 commit cfccdf8

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

README.rst

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ A minimal API
3131
from flask import Flask
3232
from flask_combo_jsonapi import Api, ResourceDetail, ResourceList
3333
from flask_sqlalchemy import SQLAlchemy
34+
from marshmallow import pre_load
3435
from marshmallow_jsonapi.flask import Schema
3536
from marshmallow_jsonapi import fields
3637
@@ -62,18 +63,18 @@ A minimal API
6263
id = fields.Integer(as_string=True, dump_only=True)
6364
name = fields.String()
6465
65-
@pre_load
66-
def remove_id_before_deserializing(self, data, **kwargs):
67-
"""
68-
We don't want to allow editing ID on POST / PATCH
69-
70-
Related issues:
71-
https://github.com/AdCombo/flask-combo-jsonapi/issues/34
72-
https://github.com/miLibris/flask-rest-jsonapi/issues/193
73-
"""
74-
if 'id' in data:
75-
del data['id']
76-
return data
66+
@pre_load
67+
def remove_id_before_deserializing(self, data, **kwargs):
68+
"""
69+
We don't want to allow editing ID on POST / PATCH
70+
71+
Related issues:
72+
https://github.com/AdCombo/flask-combo-jsonapi/issues/34
73+
https://github.com/miLibris/flask-rest-jsonapi/issues/193
74+
"""
75+
if 'id' in data:
76+
del data['id']
77+
return data
7778
7879
# Create resource managers
7980
class PersonList(ResourceList):

examples/api_minimal.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from flask import Flask
2-
from marshmallow import pre_load
3-
42
from flask_combo_jsonapi import Api, ResourceDetail, ResourceList
53
from flask_sqlalchemy import SQLAlchemy
4+
from marshmallow import pre_load
65
from marshmallow_jsonapi.flask import Schema
76
from marshmallow_jsonapi import fields
87

0 commit comments

Comments
 (0)