Skip to content

webob support #173

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

Merged
merged 3 commits into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions openapi_core/schema/parameters/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def get_raw_value(self, request):
return self.schema.default

if self.aslist and self.explode:
if hasattr(location, 'getall'):
return location.getall(self.name)
return location.getlist(self.name)

return location[self.name]
Expand Down
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ pytest-flake8
pytest-cov==2.5.1
flask
django==2.2.8; python_version>="3.0"
webob
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ tests_require =
pytest-flake8
pytest-cov
flask
webob

[options.packages.find]
exclude =
Expand Down
27 changes: 26 additions & 1 deletion tests/integration/validation/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_missing_parameter(self, validator):
def test_get_pets(self, validator):
request = MockRequest(
self.host_url, 'get', '/v1/pets',
path_pattern='/v1/pets', args={'limit': '10'},
path_pattern='/v1/pets', args={'limit': '10', 'ids': ['1', '2']},
)

result = validator.validate(request)
Expand All @@ -106,6 +106,31 @@ def test_get_pets(self, validator):
'limit': 10,
'page': 1,
'search': '',
'ids': [1, 2],
},
)

def test_get_pets_webob(self, validator):
from webob.multidict import GetDict
request = MockRequest(
self.host_url, 'get', '/v1/pets',
path_pattern='/v1/pets',
)
request.parameters.query = GetDict(
[('limit', '5'), ('ids', '1'), ('ids', '2')],
{}
)

result = validator.validate(request)

assert result.errors == []
assert result.body is None
assert result.parameters == RequestParameters(
query={
'limit': 5,
'page': 1,
'search': '',
'ids': [1, 2],
},
)

Expand Down