From 5057f7fbba17ee39ad1667d94ac2a59b95d16793 Mon Sep 17 00:00:00 2001 From: Avi Weinstock-Herman Date: Thu, 21 Apr 2016 16:14:38 -0600 Subject: [PATCH 1/2] Copy spec before validation occurs --- connexion/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/connexion/api.py b/connexion/api.py index 95073a645..61e736625 100644 --- a/connexion/api.py +++ b/connexion/api.py @@ -15,6 +15,7 @@ import logging import pathlib import sys +import copy import flask import jinja2 @@ -87,7 +88,9 @@ def __init__(self, swagger_yaml_path, base_url=None, arguments=None, logger.debug('Read specification', extra=self.specification) - validate_spec(compatibility_layer(self.specification)) + # Avoid validator having ability to modify specification + spec = copy.deepcopy(self.specification) + validate_spec(compatibility_layer(spec)) # https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#fixed-fields # If base_url is not on provided then we try to read it from the swagger.yaml or use / by default From 6614d78bf53e27ae029cb46ab110b39c71b1fff6 Mon Sep 17 00:00:00 2001 From: Avi Weinstock-Herman Date: Fri, 22 Apr 2016 09:59:38 -0600 Subject: [PATCH 2/2] Add compatability_layer back to specification --- connexion/api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/connexion/api.py b/connexion/api.py index 61e736625..0ad97c0bf 100644 --- a/connexion/api.py +++ b/connexion/api.py @@ -11,11 +11,11 @@ language governing permissions and limitations under the License. """ +import copy import json import logging import pathlib import sys -import copy import flask import jinja2 @@ -88,9 +88,10 @@ def __init__(self, swagger_yaml_path, base_url=None, arguments=None, logger.debug('Read specification', extra=self.specification) + self.specification = compatibility_layer(self.specification) # Avoid validator having ability to modify specification spec = copy.deepcopy(self.specification) - validate_spec(compatibility_layer(spec)) + validate_spec(spec) # https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#fixed-fields # If base_url is not on provided then we try to read it from the swagger.yaml or use / by default