Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hjmallon opened this issue Apr 15, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@hjmallon
Copy link

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={}
    ):
@hjmallon hjmallon added the bug Something isn't working label Apr 15, 2024
@peter-doggart
Copy link
Contributor

Hi @hjmallon When you say meant to support headers, can you point to where this is documented? Having trouble finding it!

@hjmallon
Copy link
Author

I dont think it is documented, but it is mostly implemented. See:

self.process_headers(

As I say it is just that tiny change away from working as far as I can tell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants