diff --git a/schema_salad/ref_resolver.py b/schema_salad/ref_resolver.py index 7eee213fd..22a9a14c1 100644 --- a/schema_salad/ref_resolver.py +++ b/schema_salad/ref_resolver.py @@ -97,7 +97,8 @@ def merge_properties(a, b): # type: (List[Any], List[Any]) -> Dict[Any, Any] def SubLoader(loader): # type: (Loader) -> Loader return Loader(loader.ctx, schemagraph=loader.graph, foreign_properties=loader.foreign_properties, idx=loader.idx, - cache=loader.cache, fetcher_constructor=loader.fetcher_constructor) + cache=loader.cache, fetcher_constructor=loader.fetcher_constructor, + skip_schemas=loader.skip_schemas) class Fetcher(object): def fetch_text(self, url): # type: (unicode) -> unicode @@ -179,7 +180,8 @@ def __init__(self, idx=None, # type: Dict[unicode, Union[CommentedMap, CommentedSeq, unicode, None]] cache=None, # type: Dict[unicode, Any] session=None, # type: requests.sessions.Session - fetcher_constructor=None # type: Callable[[Dict[unicode, unicode], requests.sessions.Session], Fetcher] + fetcher_constructor=None, # type: Callable[[Dict[unicode, unicode], requests.sessions.Session], Fetcher] + skip_schemas=None # type: bool ): # type: (...) -> None @@ -205,6 +207,11 @@ def __init__(self, else: self.cache = {} + if skip_schemas is not None: + self.skip_schemas = skip_schemas + else: + self.skip_schemas = False + if session is None: if "HOME" in os.environ: self.session = CacheControl( @@ -305,6 +312,8 @@ def add_namespaces(self, ns): # type: (Dict[unicode, unicode]) -> None def add_schemas(self, ns, base_url): # type: (Union[List[unicode], unicode], unicode) -> None + if self.skip_schemas: + return for sch in aslist(ns): fetchurl = self.fetcher.urljoin(base_url, sch) if fetchurl not in self.cache: