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

field2property won't pop "location" from field metadata #67

merged 2 commits into from Apr 13, 2016


Copy link

commented Apr 13, 2016

Before this change, field2property modified field's metadata by popping of location, which is unexpected behavior.

As an example, the following code would fail

field_dict = {'field': fields.Str(location='querystring')}
swagger.fields2parameters(field_dict, default_in='headers')assert res[0]['in'] == 'query'
# The first call popped off 'location' from metadata, so the 2nd call won't have the correct location
res = swagger.fields2parameters(field_dict, default_in='headers')
assert res[0]['in'] == 'query'

This behavior could have adverse consequences, especially when working with webargs.

This PR changes field2property so that it doesn't pop off location, and only valid OpenAPI properties can be added to its output.

sloria added some commits Apr 13, 2016

field2property won't pop "location" from field metadata
Only add valid OpenAPI properties to the return value

@sloria sloria merged commit 69a5b8b into dev Apr 13, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
continuous-integration/travis-ci/push The Travis CI build passed

@sloria sloria deleted the preserve-metadata branch Apr 13, 2016

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