From 825c682086683bf59e8b50d586a9e0b45e4b2e33 Mon Sep 17 00:00:00 2001 From: Robbe Sneyders Date: Mon, 14 Nov 2022 23:31:09 +0100 Subject: [PATCH] Remove strict_validation and validate_responses from API and Operation classes --- connexion/apis/abstract.py | 12 ------------ connexion/operations/abstract.py | 23 ----------------------- connexion/operations/openapi.py | 8 -------- connexion/operations/swagger2.py | 9 --------- tests/test_operation2.py | 3 +-- 5 files changed, 1 insertion(+), 54 deletions(-) diff --git a/connexion/apis/abstract.py b/connexion/apis/abstract.py index 5706b6aed..06128f901 100644 --- a/connexion/apis/abstract.py +++ b/connexion/apis/abstract.py @@ -181,8 +181,6 @@ def __init__( specification, base_path=None, arguments=None, - validate_responses=False, - strict_validation=False, resolver=None, debug=False, resolver_error_handler=None, @@ -191,19 +189,11 @@ def __init__( **kwargs, ): """ - :type validate_responses: bool - :type strict_validation: bool :type resolver_error_handler: callable | None :param pythonic_params: When True CamelCase parameters are converted to snake_case and an underscore is appended to any shadowed built-ins :type pythonic_params: bool """ - logger.debug("Validate Responses: %s", str(validate_responses)) - self.validate_responses = validate_responses - - logger.debug("Strict Request Validation: %s", str(strict_validation)) - self.strict_validation = strict_validation - logger.debug("Pythonic params: %s", str(pythonic_params)) self.pythonic_params = pythonic_params @@ -239,8 +229,6 @@ def add_operation(self, path, method): path, method, self.resolver, - validate_responses=self.validate_responses, - strict_validation=self.strict_validation, pythonic_params=self.pythonic_params, uri_parser_class=self.options.uri_parser_class, ) diff --git a/connexion/operations/abstract.py b/connexion/operations/abstract.py index fa0355f5b..eec082e27 100644 --- a/connexion/operations/abstract.py +++ b/connexion/operations/abstract.py @@ -44,8 +44,6 @@ def __init__( resolver, app_security=None, security_schemes=None, - validate_responses=False, - strict_validation=False, randomize_endpoint=None, pythonic_params=False, uri_parser_class=None, @@ -65,10 +63,6 @@ def __init__( :param security_schemes: `Security Definitions Object `_ :type security_schemes: dict - :param validate_responses: True enables validation. Validation errors generate HTTP 500 responses. - :type validate_responses: bool - :param strict_validation: True enables validation on invalid request parameters - :type strict_validation: bool :param randomize_endpoint: number of random characters to append to operation name :type randomize_endpoint: integer :param pythonic_params: When True CamelCase parameters are converted to snake_case and an underscore is appended @@ -84,8 +78,6 @@ def __init__( self._resolver = resolver self._security = operation.get("security", app_security) self._security_schemes = security_schemes - self._validate_responses = validate_responses - self._strict_validation = strict_validation self._pythonic_params = pythonic_params self._uri_parser_class = uri_parser_class self._randomize_endpoint = randomize_endpoint @@ -150,13 +142,6 @@ def router_controller(self): """ return self._router_controller - @property - def strict_validation(self): - """ - If True, validate all requests against the spec - """ - return self._strict_validation - @property def pythonic_params(self): """ @@ -164,14 +149,6 @@ def pythonic_params(self): """ return self._pythonic_params - @property - def validate_responses(self): - """ - If True, check the response against the response schema, and return an - error if the response does not validate. - """ - return self._validate_responses - @staticmethod def _get_file_arguments(files, arguments, has_kwargs=False): return {k: v for k, v in files.items() if k in arguments or has_kwargs} diff --git a/connexion/operations/openapi.py b/connexion/operations/openapi.py index 7f301b827..3d253dc17 100644 --- a/connexion/operations/openapi.py +++ b/connexion/operations/openapi.py @@ -32,8 +32,6 @@ def __init__( app_security=None, security_schemes=None, components=None, - validate_responses=False, - strict_validation=False, randomize_endpoint=None, pythonic_params=False, uri_parser_class=None, @@ -65,10 +63,6 @@ def __init__( :param components: `Components Object `_ :type components: dict - :param validate_responses: True enables validation. Validation errors generate HTTP 500 responses. - :type validate_responses: bool - :param strict_validation: True enables validation on invalid request parameters - :type strict_validation: bool :param randomize_endpoint: number of random characters to append to operation name :type randomize_endpoint: integer :param pythonic_params: When True CamelCase parameters are converted to snake_case and an underscore is appended @@ -91,8 +85,6 @@ def __init__( resolver=resolver, app_security=app_security, security_schemes=security_schemes, - validate_responses=validate_responses, - strict_validation=strict_validation, randomize_endpoint=randomize_endpoint, pythonic_params=pythonic_params, uri_parser_class=uri_parser_class, diff --git a/connexion/operations/swagger2.py b/connexion/operations/swagger2.py index f1211ea4d..ad5c1046b 100644 --- a/connexion/operations/swagger2.py +++ b/connexion/operations/swagger2.py @@ -49,8 +49,6 @@ def __init__( app_security=None, security_schemes=None, definitions=None, - validate_responses=False, - strict_validation=False, randomize_endpoint=None, pythonic_params=False, uri_parser_class=None, @@ -80,10 +78,6 @@ def __init__( :param definitions: `Definitions Object `_ :type definitions: dict - :param validate_responses: True enables validation. Validation errors generate HTTP 500 responses. - :type validate_responses: bool - :param strict_validation: True enables validation on invalid request parameters - :type strict_validation: bool :param randomize_endpoint: number of random characters to append to operation name :type randomize_endpoint: integer :param pythonic_params: When True CamelCase parameters are converted to snake_case and an underscore is appended @@ -104,8 +98,6 @@ def __init__( resolver=resolver, app_security=app_security, security_schemes=security_schemes, - validate_responses=validate_responses, - strict_validation=strict_validation, randomize_endpoint=randomize_endpoint, pythonic_params=pythonic_params, uri_parser_class=uri_parser_class, @@ -314,7 +306,6 @@ def _transform_form(self, form_parameters: t.List[dict]) -> dict: "type": "object", "properties": properties, "required": required, - "additionalProperties": not self.strict_validation, } } diff --git a/tests/test_operation2.py b/tests/test_operation2.py index 2e169979f..2ac20839e 100644 --- a/tests/test_operation2.py +++ b/tests/test_operation2.py @@ -706,7 +706,7 @@ def test_oauth_scopes_in_or(security_handler_factory): def test_form_transformation(api): - mock_self = mock.Mock(strict_validation=True) + mock_self = mock.Mock() swagger_form_parameters = [ { @@ -747,7 +747,6 @@ def test_form_transformation(api): }, }, "required": ["param"], - "additionalProperties": False, }, "encoding": { "array_param": {