-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Hi @jbwyme, this package is working really nicely for me. One problem I've had is that the jsonschema RefResolver is recreated for each validation, and thus it pulls external $ref's when they could otherwise be cached.
I have a change that fixes this by creating and caching one when the schema is looked up. For example, in Resolver.lookup_schema:
ref_resolver = jsonschema.RefResolver.from_schema(lookup_result)
self.cache[schema_path] = [lookup_result, ref_resolver, store_time]
return lookup_result, ref_resolverThen that is passed to validation like this:
schema, ref_resolver = resolver.lookup_schema(self.schema_key)
jsonschema.validate(
instance=self.data,
schema=schema,
resolver=ref_resolver,
format_checker=jsonschema.FormatChecker(),
)I'm not sure if this is the proper way to do this, so I didn't submit a PR yet. Is there perhaps an easier way to do this that you are aware of?
Metadata
Metadata
Assignees
Labels
No labels