mirror of
https://github.com/correl/openapi-core.git
synced 2025-01-01 11:03:19 +00:00
commit
4b712cb2b5
4 changed files with 30 additions and 1 deletions
|
@ -87,6 +87,8 @@ class Parameter(object):
|
|||
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]
|
||||
|
|
|
@ -4,3 +4,4 @@ pytest-flake8
|
|||
pytest-cov==2.5.1
|
||||
flask
|
||||
django==2.2.8; python_version>="3.0"
|
||||
webob
|
||||
|
|
|
@ -37,6 +37,7 @@ tests_require =
|
|||
pytest-flake8
|
||||
pytest-cov
|
||||
flask
|
||||
webob
|
||||
|
||||
[options.packages.find]
|
||||
exclude =
|
||||
|
|
|
@ -94,7 +94,7 @@ class TestRequestValidator(object):
|
|||
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)
|
||||
|
@ -106,6 +106,31 @@ class TestRequestValidator(object):
|
|||
'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],
|
||||
},
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue