From 75f05f645c42ab8fc949ff3e86c5d6eb11ada8b0 Mon Sep 17 00:00:00 2001 From: Daniel Opitz Date: Wed, 22 Nov 2017 16:53:47 +0100 Subject: [PATCH] add validators to existing validators to not omit any - fixes #138 --- flex/validation/parameter.py | 5 ++++- .../request/test_request_body_parameter_validation.py | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/flex/validation/parameter.py b/flex/validation/parameter.py index 5bfb4cb..5ffd4d8 100644 --- a/flex/validation/parameter.py +++ b/flex/validation/parameter.py @@ -125,7 +125,10 @@ def construct_parameter_validators(parameter, context): if 'schema' in parameter: schema_validators = construct_schema_validators(parameter['schema'], context=context) for key, value in schema_validators.items(): - validators.setdefault(key, value) + if key in validators: + validators[key] += value + else: + validators.setdefault(key, value) return validators diff --git a/tests/validation/request/test_request_body_parameter_validation.py b/tests/validation/request/test_request_body_parameter_validation.py index 03b3502..a5c88f2 100644 --- a/tests/validation/request/test_request_body_parameter_validation.py +++ b/tests/validation/request/test_request_body_parameter_validation.py @@ -121,19 +121,19 @@ def test_request_body_parameter_validation_invalid_without_ref(): schema = SchemaFactory( paths={ '/post/': { - 'post': { + POST: { 'consumes': ['application/json'], 'parameters': [ { - 'in': 'body', - 'name': 'body', + 'in': BODY, + 'name': BODY, 'required': True, 'schema': { - 'type': 'object', + 'type': OBJECT, 'required': ['name'], 'properties': { 'name': { - 'type': 'string' + 'type': STRING } } }