5

With:

@api.marshal_with(response_model, code=200)

We can marshal a response with a predefined response model response_model and a status code.

My question is let's say we run a validation on the request and we want to throw a 400 error.

Is it possible to marshal the same method with a different model and a different code with:

@api.marshal_with(response_model_2, code=400)
Franco Piccolo
  • 6,845
  • 8
  • 34
  • 52
  • if you will just do @api.marshal_with(response_model) and return {}, 200 or return {}, 400 the status code accordingly changes – Hashir Irfan Apr 18 '22 at 11:28

0 Answers0