Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_val_from_param(value, query_param):
if is_nullable(query_param) and is_null(value):
return None
if query_param["type"] == "array": # then logic is more complex
if query_param.get("collectionFormat") and query_param.get("collectionFormat") == "pipes":
parts = value.split("|")
else: # default: csv
parts = value.split(",")
return [make_type(part, query_param["items"]["type"]) for part in parts]
else:
return make_type(value, query_param["type"])
def validate_schema(self, data, url):
# type: (dict, AnyStr) -> Union[ConnexionResponse, None]
if self.is_null_value_valid and is_null(data):
return None
try:
self.validator.validate(data)
except ValidationError as exception:
error_path = '.'.join(str(item) for item in exception.path)
error_path_msg = " - '{path}'".format(path=error_path) \
if error_path else ""
logger.error(
"{url} validation error: {error}{error_path_msg}".format(
url=url, error=exception.message,
error_path_msg=error_path_msg),
extra={'validator': 'body'})
raise BadRequestProblem(detail="{message}{error_path_msg}".format(
message=exception.message,
error_path_msg=error_path_msg))
def _get_val_from_param(self, value, query_defn):
if is_nullable(query_defn) and is_null(value):
return None
query_schema = query_defn
if query_schema["type"] == "array":
return [make_type(part, query_defn["items"]["type"]) for part in value]
else:
return make_type(value, query_defn["type"])