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

fix: make Wildcard fields support Nested and List fields (fix #728) #739

Merged
merged 1 commit into from
Oct 27, 2019

Conversation

ziirish
Copy link
Collaborator

@ziirish ziirish commented Oct 18, 2019

This allows you to use fields.Nested or fields.List as Wildcard inner fields.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 96.836% when pulling 0045498 on ziirish:wildcard-nested into 9b9ad42 on noirbizarre:master.

@j5awry j5awry mentioned this pull request Oct 27, 2019
@SteadBytes SteadBytes merged commit 823f61e into noirbizarre:master Oct 27, 2019
@Killerjay666
Copy link

Is there an example of its usage anywhere?

I would like to use it for a nested dictionary, but cannot seem to figure out the correct syntax.

@ziirish
Copy link
Collaborator Author

ziirish commented Nov 14, 2019

Is there an example of its usage anywhere?

I would like to use it for a nested dictionary, but cannot seem to figure out the correct syntax.

There is an example here and another one here

I'll have a look at improving the doc for such use-case.

@Killerjay666
Copy link

Hi Ziirish,

thanks a lot for your (very quick) response. The examples are very useful.

I believe I am following pretty much the same syntax as here:

nest = fields.List(fields.Nested(span_templates_model_post))
wild = fields.Wildcard(nest)
wildcard_field =  {'*': wild}

templates_model_post = api.model("TemplateModelPost", {
    "fields": fields.Nested(wildcard_field)
})

However, trying to use this model for marshalling, gives me the following error:
File "/Users/jens/.virtualenvs/alfred/lib/python3.7/site-packages/flask_restplus/fields.py", line 225, in output return marshal(value, self.nested, skip_none=self.skip_none, ordered=ordered) File "/Users/jens/.virtualenvs/alfred/lib/python3.7/site-packages/flask_restplus/marshalling.py", line 92, in marshal value == field.container.format(field.default): File "/Users/jens/.virtualenvs/alfred/lib/python3.7/site-packages/flask_restplus/fields.py", line 287, in format for idx, val in enumerate(value) TypeError: 'NoneType' object is not iterable

@ziirish
Copy link
Collaborator Author

ziirish commented Nov 14, 2019

The current patch is not yet available in any stable release. What version of Flask-RESTPlus are you using?

We are in the process of releasing a new stable version, but we are waiting for the main developer (@noirbizarre) to push that release on Pypi.

@Killerjay666
Copy link

Killerjay666 commented Nov 15, 2019 via email

@j5awry
Copy link
Collaborator

j5awry commented Nov 16, 2019

you can do a pip install git+ssh as well. Unfortunately, only one person has keys to release, and we've been unable to get ahold of that person for several weeks now. We've got an open ticket to cut a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants