Skip to content

Commit 9b4bf7e

Browse files
committed
see if we can use this to correctly validate some schemas
1 parent b584131 commit 9b4bf7e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

st2common/st2common/util/schema/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,16 @@ def validate(
419419
:type use_default: ``bool``
420420
"""
421421
instance = fast_deepcopy_dict(instance)
422-
schema_type = schema.get("type", None)
422+
schema_type = None
423+
if isinstance(schema, dict):
424+
schema_type = schema.get("type", None)
425+
423426
instance_is_dict = isinstance(instance, dict)
424427

428+
if isinstance(schema, dict) and ("type" in schema or "$schema" in schema):
429+
jsonschema.validate(instance=instance, schema=schema, *args, **kwargs)
430+
return instance
431+
425432
if use_default and allow_default_none:
426433
schema = modify_schema_allow_default_none(schema=schema)
427434

0 commit comments

Comments
 (0)