diff --git a/swagger_py_codegen/_version.py b/swagger_py_codegen/_version.py index 811eb05..1da5f08 100644 --- a/swagger_py_codegen/_version.py +++ b/swagger_py_codegen/_version.py @@ -1,4 +1,4 @@ """Version information.""" # The following line *must* be the last in the module, exactly as formatted: -__version__ = "0.3.6" +__version__ = "0.3.7" diff --git a/swagger_py_codegen/parser.py b/swagger_py_codegen/parser.py index ca5a803..42710de 100644 --- a/swagger_py_codegen/parser.py +++ b/swagger_py_codegen/parser.py @@ -45,7 +45,7 @@ def __eq__(self, other): return False def __deepcopy__(self, memo): - return RefNode(self._data, self.ref) + return RefNode(copy.deepcopy(self._data), self.ref) def copy(self): return RefNode(self._data, self.ref) diff --git a/swagger_py_codegen/templates/falcon/blueprint.tpl b/swagger_py_codegen/templates/falcon/blueprint.tpl index d4c8b0d..b2b4228 100644 --- a/swagger_py_codegen/templates/falcon/blueprint.tpl +++ b/swagger_py_codegen/templates/falcon/blueprint.tpl @@ -4,7 +4,7 @@ from __future__ import absolute_import, print_function import falcon from .routes import routes -from .validators import security +from .validators import security, current @security.scopes_loader diff --git a/swagger_py_codegen/templates/falcon/validators.tpl b/swagger_py_codegen/templates/falcon/validators.tpl index 965dde3..7cf4ca9 100644 --- a/swagger_py_codegen/templates/falcon/validators.tpl +++ b/swagger_py_codegen/templates/falcon/validators.tpl @@ -33,6 +33,14 @@ def _path_to_endpoint(path): return _remove_characters(endpoint, '{}') +class Current(object): + + request = None + + +current = Current() + + class JSONEncoder(json.JSONEncoder): def default(self, o): @@ -92,11 +100,12 @@ class FalconValidatorAdaptor(object): def request_validate(req, resp, resource, params): + current.request = req endpoint = _path_to_endpoint(req.uri_template) # scope if (endpoint, req.method) in scopes and not set( scopes[(endpoint, req.method)]).issubset(set(security.scopes)): - falcon.HTTPUnauthorized('403403403') + raise falcon.HTTPUnauthorized('invalid client') # data method = req.method if method == 'HEAD': @@ -113,11 +122,11 @@ def request_validate(req, resp, resource, params): try: value = json.loads(body.decode('utf-8')) except (ValueError, UnicodeDecodeError): - raise falcon.HTTPError(falcon.HTTP_753, - 'Malformed JSON', - 'Could not decode the request body. The ' - 'JSON was incorrect or not encoded as ' - 'UTF-8.') + raise falcon.HTTPUnprocessableEntity( + 'Malformed JSON', + 'Could not decode the request body. The ' + 'JSON was incorrect or not encoded as ' + 'UTF-8.') if value is None: value = MultiDict() validator = FalconValidatorAdaptor(schema)