mirror of
https://github.com/correl/openapi-core.git
synced 2025-01-01 11:03:19 +00:00
add test to check parameter uniqueness is handled correctly in validator
This commit is contained in:
parent
d490d5774b
commit
3d23f17c1d
1 changed files with 24 additions and 2 deletions
|
@ -306,8 +306,7 @@ class TestPathItemParamsValidator(object):
|
|||
assert result.parameters == {'query': {'resId': 10}}
|
||||
|
||||
def test_request_override_param(self, spec_dict):
|
||||
# override parameter path parameter on operation
|
||||
# (name and in property must match)
|
||||
# override path parameter on operation
|
||||
spec_dict["paths"]["/resource"]["get"]["parameters"] = [
|
||||
{
|
||||
# full valid parameter object required
|
||||
|
@ -327,6 +326,29 @@ class TestPathItemParamsValidator(object):
|
|||
assert result.body is None
|
||||
assert result.parameters == {}
|
||||
|
||||
def test_request_override_param_uniqueness(self, spec_dict):
|
||||
# add parameter on operation with same name as on path but
|
||||
# different location
|
||||
spec_dict["paths"]["/resource"]["get"]["parameters"] = [
|
||||
{
|
||||
# full valid parameter object required
|
||||
"name": "resId",
|
||||
"in": "header",
|
||||
"required": False,
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
},
|
||||
}
|
||||
]
|
||||
validator = RequestValidator(create_spec(spec_dict))
|
||||
request = MockRequest('http://example.com', 'get', '/resource')
|
||||
result = validator.validate(request)
|
||||
|
||||
assert len(result.errors) == 1
|
||||
assert type(result.errors[0]) == MissingRequiredParameter
|
||||
assert result.body is None
|
||||
assert result.parameters == {}
|
||||
|
||||
|
||||
class TestResponseValidator(object):
|
||||
|
||||
|
|
Loading…
Reference in a new issue