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

allow_missing=True not working with nested args on passing null #51

Closed
ghost opened this issue Jul 1, 2015 · 1 comment

Comments

@ghost
Copy link

commented Jul 1, 2015

I'm trying to follow jsonapi's spec on updating relationships, so I made the following args

args = {
    'data': Arg({
        'type': Arg(str, required=True, target='json'),
        'id': Arg(int, required=True, target='json')
    }, required=False, allow_missing=True)
}

@private.route('/departments/<int:dept_id>/relationships/companies', methods=['PATCH'])
@use_args(args, locations=('json',))
def function(args, dept_id):
    ...

here I'm expecting that when I pass an object in data, it will try to validate it if it has the necessary fields (type and id) and when I pass null it will continue on and give me dict object of {data: None}, but only the former is working, if I try to pass null it gives me an 422 UNPROCESSABLE ENTITY error saying "Expected type 'object' for data, got 'null'"

as mentioned in #9 , with allow_missing=True values will only be excluded if they are not found on the request; otherwise if given value of null then it will be included in the parsed arguments.

@ghost ghost changed the title allow_missing=True not working with nested args allow_missing=True not working with nested args on passing null Jul 1, 2015

@sloria

This comment has been minimized.

Copy link
Member

commented Sep 27, 2015

This is now fixed by virtue of using marshmallow's Nested field.

@sloria sloria closed this Sep 27, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.