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

Adjust field name in spec according to `load_from` and `dump_to`. #43

Merged
merged 1 commit into from Dec 28, 2015

Conversation

@jta
Copy link
Contributor

commented Dec 21, 2015

In marshmallow you can work around clashes with reserved names (e.g.
global) by using the load_from and dump_to attributes in a field
to effectively override the actual field name.

Doing so implicitly changes the schema however, and this commit attempts
to correct for that by replacing the field name with the values of
load_from and dump_to if they are the same.

An open question is what to do if dump_to and load_from differ. In
this case in practice the input schema differs from the output schema,
but there is no simple way of generating two schemas for the same
definition, and it's probably too much of an edge case to bother with.

Adjust field name in spec according to `load_from` and `dump_to`.
In marshmallow you can work around clashes with reserved names (e.g.
`global`) by using the `load_from` and `dump_to` attributes in a field
to effectively override the actual field name.

Doing so implicitly changes the schema however, and this commit attempts
to correct for that by replacing the field name with the values of
`load_from` and `dump_to` if they are the same.

An open question is what to do if `dump_to` and `load_from` differ. In
this case in practice the input schema differs from the output schema,
but there is no simple way of generating two schemas for the same
definition, and it's probably too much of an edge case to bother with.
@sloria

This comment has been minimized.

Copy link
Member

commented Dec 28, 2015

Looks good. Thanks!

sloria added a commit that referenced this pull request Dec 28, 2015

Merge pull request #43 from jta/dev
Adjust field name in spec according to `load_from` and `dump_to`.

@sloria sloria merged commit dee6a3e into marshmallow-code:dev Dec 28, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.