Skip to content

Identify local object definitions and recurse over the properties#186

Merged
sloria merged 1 commit intomarshmallow-code:devfrom
lphuberdeau:recurse-partial-schema-definitions
Apr 5, 2018
Merged

Identify local object definitions and recurse over the properties#186
sloria merged 1 commit intomarshmallow-code:devfrom
lphuberdeau:recurse-partial-schema-definitions

Conversation

@lphuberdeau
Copy link
Copy Markdown
Contributor

This adds a little bit of consistency allowing object definitions as part of the response - not only arrays. My primary case for this is to wrap all of our responses in a data property without having to declare a custom schema for each data type individually.

@lafrech
Copy link
Copy Markdown
Member

lafrech commented Apr 1, 2018

IIUC, you're stepping into the object to identify properties using known schemas. If we go this route, why stop at the first level and not recurse through the whole schemas?

Also, it looks like your use case is similar to http://marshmallow.readthedocs.io/en/latest/extending.html#example-enveloping. I'm not sure how to use this pre_load/post_dump trick with apispec, though

@lphuberdeau
Copy link
Copy Markdown
Contributor Author

The patch does recurse through the entire structure of object definitions as the same function is called for each matching child entry.

@lafrech
Copy link
Copy Markdown
Member

lafrech commented Apr 3, 2018

Oh, right. Sorry.

I don't have any objection to this PR.

@sloria
Copy link
Copy Markdown
Member

sloria commented Apr 5, 2018

Good change. Thanks @lphuberdeau!

@sloria sloria merged commit cfa627f into marshmallow-code:dev Apr 5, 2018
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.

3 participants