Skip to content

@api.marshal_with is meant to support headers but gets unexpected keyword argument #601

Open
@hjmallon

Description

@hjmallon
class World(Resource):
    @api.marshal_with(bay_model, headers={"x-my-header": "description"})
    def get(self, id):
        reuturn {"hello": "world"}

Repro Steps (if applicable)

  1. Use a response specific header with marshal_with
  2. 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={}
    ):

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions