Skip to content

Commit

Permalink
Remove strict_validation and validate_responses from API and Operatio…
Browse files Browse the repository at this point in the history
…n classes
  • Loading branch information
RobbeSneyders committed Nov 14, 2022
1 parent 2581a7e commit 825c682
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 54 deletions.
12 changes: 0 additions & 12 deletions connexion/apis/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down Expand Up @@ -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,
)
Expand Down
23 changes: 0 additions & 23 deletions connexion/operations/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -65,10 +63,6 @@ def __init__(
:param security_schemes: `Security Definitions Object
<https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#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
Expand All @@ -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
Expand Down Expand Up @@ -150,28 +142,13 @@ 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):
"""
If True, convert CamelCase into pythonic_variable_names
"""
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}
Expand Down
8 changes: 0 additions & 8 deletions connexion/operations/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -65,10 +63,6 @@ def __init__(
:param components: `Components Object
<https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#componentsObject>`_
: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
Expand All @@ -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,
Expand Down
9 changes: 0 additions & 9 deletions connexion/operations/swagger2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -80,10 +78,6 @@ def __init__(
:param definitions: `Definitions Object
<https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#definitionsObject>`_
: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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
}
}

Expand Down
3 changes: 1 addition & 2 deletions tests/test_operation2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -747,7 +747,6 @@ def test_form_transformation(api):
},
},
"required": ["param"],
"additionalProperties": False,
},
"encoding": {
"array_param": {
Expand Down

0 comments on commit 825c682

Please sign in to comment.