Skip to content

Commit

Permalink
Tweaks args to handle_request()
Browse files Browse the repository at this point in the history
  • Loading branch information
Semir Patel committed Apr 23, 2015
1 parent 96879c1 commit dfe22aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions pyramid_swagger/tween.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ def validator_tween(request):
if settings.validate_request:
request_data = swagger_handler.handle_request(
PyramidSwaggerRequest(request, route_info),
validation_context=validation_context,
validator_map=op_or_validators_map,
op=op_or_validators_map)
op_or_validators_map,
validation_context=validation_context)

def swagger_data(_):
return request_data
Expand Down Expand Up @@ -200,16 +199,16 @@ def json(self, **kwargs):
return getattr(self.request, 'json_body', {})


def handle_request(request, validation_context, validator_map, **kwargs):
def handle_request(request, validator_map, validation_context, **kwargs):
"""Validate the request against the swagger spec and return a dict with
all parameter values available in the request, casted to the expected
python type.
:param request: a :class:`PyramidSwaggerRequest` to validate
:param validation_context: a context manager for wrapping validation
errors
:param validator_map: a :class:`pyramid_swagger.load_schema.ValidatorMap`
used to validate the request
:param validation_context: a context manager for wrapping validation
errors
:returns: a :class:`dict` of request data for each parameter in the swagger
spec
"""
Expand Down Expand Up @@ -435,7 +434,7 @@ def prepare_body(response):


@validation_error(RequestValidationError)
def swaggerize_request(request, **kwargs):
def swaggerize_request(request, op, **kwargs):
"""
Delegate handling the Swagger concerns of the request to bravado-core.
Post-invocation, the Swagger request parameters are available as a dict
Expand All @@ -445,7 +444,6 @@ def swaggerize_request(request, **kwargs):
:type op: :class:`bravado_core.operation.Operation`
:type validatation_context: context manager
"""
op = kwargs['op']
validation_context = kwargs['validation_context']
with validation_context(request):
request_data = unmarshal_request(request, op)
Expand Down
2 changes: 1 addition & 1 deletion tests/tween_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_handle_request_returns_request_data():
'bar': {'more': 'foo'},
}

request_data = handle_request(mock_request, noop_context, validator_map)
request_data = handle_request(mock_request, validator_map, noop_context,)
assert request_data == expected


Expand Down

0 comments on commit dfe22aa

Please sign in to comment.