@api.marshal_with is meant to support headers but gets unexpected keyword argument
hjmallon opened this issue · comments
Harry Mallon commented
class World(Resource):
@api.marshal_with(bay_model, headers={"x-my-header": "description"})
def get(self, id):
reuturn {"hello": "world"}
Repro Steps (if applicable)
- Use a response specific header with marshal_with
- Get an unexpected keyword argument error
Expected Behavior
Make a response specific header doc
Actual Behavior
Raises error
Error Messages/Stack Trace
return marshal_with(fields, ordered=self.ordered, **kwargs)(func)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: marshal_with.__init__() got an unexpected keyword argument 'headers'
Possible fix?
I think it can be fixed by adding headers={}
to __init__
in marshal_with.
def __init__(
self, fields, envelope=None, skip_none=False, mask=None, ordered=False, headers={}
):
Peter Doggart commented
Hi @hjmallon When you say meant to support headers, can you point to where this is documented? Having trouble finding it!
Harry Mallon commented
I dont think it is documented, but it is mostly implemented. See:
flask-restx/flask_restx/swagger.py
Line 613 in 29dd1fa
As I say it is just that tiny change away from working as far as I can tell