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

Unable to access nested list property using dot(.) notation as specified in documentation. #91

Closed
mukeshsharma1201 opened this issue Mar 17, 2020 · 4 comments · Fixed by #93
Labels
bug Something isn't working

Comments

@mukeshsharma1201
Copy link

Code

field = fields.Raw(attribute='bar.0')
assert field.output('foo', {'bar': [42]}) == 42

Repro Steps (if applicable)
Try with the above snippet

Expected Behavior
Properties which are nested under list should be accessible according to https://flask-restplus.readthedocs.io/en/stable/marshalling.html#renaming-attributes
AND
https://flask-restx.readthedocs.io/en/latest/marshalling.html#renaming-attributes

Actual Behavior
A description of the unexpected, buggy behaviour.

Error Messages/Stack Trace
No error/exception thrown, but it outputs None

Environment
Python 3.7.2
Flask 1.1.1
Werkzeug 0.16.1
Flask-RESTPlus 0.13.0
flask-restx 0.1.1

Additional Context

This is the exact issue #783 of flask-restplus. Since I am experiencing the same behaviour in flask-restx and there are no previous issues mentioning this, so I am creating an exact copy of the issue here!

There is an open PR on flask-restplus that solves the issue. I am just beginner with python and flask-restx, but if anyone can port that solution here, it would be great!

@mukeshsharma1201 mukeshsharma1201 added the bug Something isn't working label Mar 17, 2020
@arajkumar
Copy link
Contributor

Hey, I can port the change to this active project. Thanks !

@mukeshsharma1201
Copy link
Author

That's awesome @arajkumar!
Thank you so much, Hope this gets merged soon! 😄

@mukeshsharma1201
Copy link
Author

Till this gets fixed I am using functions as a workaround

def getItem(x):
  return x[0]

field = fields.Raw(attribute=getItem)

@j5awry
Copy link
Contributor

j5awry commented Mar 18, 2020

I've confirmed the bug, and looking at the PR now.

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

Successfully merging a pull request may close this issue.

3 participants