@@ -128,7 +128,7 @@ def get(self, *args, **kwargs):
128
128
qs ,
129
129
qs .include )
130
130
131
- result = schema .dump (objects ). data
131
+ result = schema .dump (objects )
132
132
133
133
view_kwargs = request .view_args if getattr (self , 'view_kwargs' , None ) is True else dict ()
134
134
add_pagination_links (result ,
@@ -157,7 +157,7 @@ def post(self, *args, **kwargs):
157
157
qs .include )
158
158
159
159
try :
160
- data , errors = schema .load (json_data )
160
+ data = schema .load (json_data )
161
161
except IncorrectTypeError as e :
162
162
errors = e .messages
163
163
for error in errors ['errors' ]:
@@ -171,17 +171,11 @@ def post(self, *args, **kwargs):
171
171
message ['title' ] = "Validation error"
172
172
return errors , 422
173
173
174
- if errors :
175
- for error in errors ['errors' ]:
176
- error ['status' ] = "422"
177
- error ['title' ] = "Validation error"
178
- return errors , 422
179
-
180
174
self .before_post (args , kwargs , data = data )
181
175
182
176
obj = self .create_object (data , kwargs )
183
177
184
- result = schema .dump (obj ). data
178
+ result = schema .dump (obj )
185
179
186
180
if result ['data' ].get ('links' , {}).get ('self' ):
187
181
final_result = (result , 201 , {'Location' : result ['data' ]['links' ]['self' ]})
@@ -237,7 +231,7 @@ def get(self, *args, **kwargs):
237
231
qs ,
238
232
qs .include )
239
233
240
- result = schema .dump (obj ). data
234
+ result = schema .dump (obj )
241
235
242
236
final_result = self .after_get (result )
243
237
@@ -260,7 +254,7 @@ def patch(self, *args, **kwargs):
260
254
qs .include )
261
255
262
256
try :
263
- data , errors = schema .load (json_data )
257
+ data = schema .load (json_data )
264
258
except IncorrectTypeError as e :
265
259
errors = e .messages
266
260
for error in errors ['errors' ]:
@@ -274,12 +268,6 @@ def patch(self, *args, **kwargs):
274
268
message ['title' ] = "Validation error"
275
269
return errors , 422
276
270
277
- if errors :
278
- for error in errors ['errors' ]:
279
- error ['status' ] = "422"
280
- error ['title' ] = "Validation error"
281
- return errors , 422
282
-
283
271
if 'id' not in json_data ['data' ]:
284
272
raise BadRequest ('Missing id in "data" node' ,
285
273
source = {'pointer' : '/data/id' })
@@ -291,7 +279,7 @@ def patch(self, *args, **kwargs):
291
279
292
280
obj = self .update_object (data , qs , kwargs )
293
281
294
- result = schema .dump (obj ). data
282
+ result = schema .dump (obj )
295
283
296
284
final_result = self .after_patch (result )
297
285
@@ -375,7 +363,7 @@ def get(self, *args, **kwargs):
375
363
schema = compute_schema (self .schema , dict (), qs , qs .include )
376
364
377
365
serialized_obj = schema .dump (obj )
378
- result ['included' ] = serialized_obj .data . get ('included' , dict ())
366
+ result ['included' ] = serialized_obj .get ('included' , dict ())
379
367
380
368
final_result = self .after_get (result )
381
369
0 commit comments