Parameter get_value restructure

This commit is contained in:
Artur Maciag 2018-08-17 14:29:41 +01:00
parent da9838b3ac
commit 7aaa5170a6

View file

@ -75,9 +75,7 @@ class Parameter(object):
def get_value(self, request): def get_value(self, request):
location = request.parameters[self.location.value] location = request.parameters[self.location.value]
try: if self.name not in location:
raw = location[self.name]
except KeyError:
if self.required: if self.required:
raise MissingRequiredParameter( raise MissingRequiredParameter(
"Missing required `{0}` parameter".format(self.name)) "Missing required `{0}` parameter".format(self.name))
@ -86,12 +84,12 @@ class Parameter(object):
raise MissingParameter( raise MissingParameter(
"Missing `{0}` parameter".format(self.name)) "Missing `{0}` parameter".format(self.name))
raw = self.schema.default return self.schema.default
if self.aslist and self.explode: if self.aslist and self.explode:
return location.getlist(self.name) return location.getlist(self.name)
return raw return location[self.name]
def unmarshal(self, value): def unmarshal(self, value):
if self.deprecated: if self.deprecated: