mirror of
https://github.com/correl/openapi-core.git
synced 2025-01-04 03:00:15 +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}}
|
assert result.parameters == {'query': {'resId': 10}}
|
||||||
|
|
||||||
def test_request_override_param(self, spec_dict):
|
def test_request_override_param(self, spec_dict):
|
||||||
# override parameter path parameter on operation
|
# override path parameter on operation
|
||||||
# (name and in property must match)
|
|
||||||
spec_dict["paths"]["/resource"]["get"]["parameters"] = [
|
spec_dict["paths"]["/resource"]["get"]["parameters"] = [
|
||||||
{
|
{
|
||||||
# full valid parameter object required
|
# full valid parameter object required
|
||||||
|
@ -327,6 +326,29 @@ class TestPathItemParamsValidator(object):
|
||||||
assert result.body is None
|
assert result.body is None
|
||||||
assert result.parameters == {}
|
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):
|
class TestResponseValidator(object):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue