Comment 8 for bug 1596573

Revision history for this message
Cyril Roelandt (cyril-roelandt) wrote :

Confirmed for glance: https://bugs.launchpad.net/glance/+bug/1596598

See Model.validate() warlock/model.py: if self.resolver is set, it is passed to jsonschema.validate(). Here is the diff:

@@ -130,6 +137,9 @@ class Model(dict):
     def validate(self, obj):
         """Apply a JSON schema to an object"""
         try:
- jsonschema.validate(obj, self.schema)
+ if self.resolver is not None:
+ jsonschema.validate(obj, self.schema, resolver=self.resolver)
+ else:
+ jsonschema.validate(obj, self.schema)
         except jsonschema.ValidationError as exc:
             raise exceptions.ValidationError(str(exc))

Here, self.resolver is a SchemaBasedModel instance. We should probably write a "resolving" method for this class, WDYT?