From 3d23f17c1d1c02f1ee291dcf4c6a8b00c3f506e0 Mon Sep 17 00:00:00 2001 From: Gerhard Weis Date: Thu, 20 Jun 2019 06:38:00 +1000 Subject: [PATCH] add test to check parameter uniqueness is handled correctly in validator --- tests/integration/test_validators.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_validators.py b/tests/integration/test_validators.py index b244381..2f26a7b 100644 --- a/tests/integration/test_validators.py +++ b/tests/integration/test_validators.py @@ -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):