Is there a way to marshal different response codes in flask_restx?

Viewed 210

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)
0 Answers
Related