本文整理汇总了Python中jsonschema.RefResolver.from_schema方法的典型用法代码示例。如果您正苦于以下问题:Python RefResolver.from_schema方法的具体用法?Python RefResolver.from_schema怎么用?Python RefResolver.from_schema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsonschema.RefResolver
的用法示例。
在下文中一共展示了RefResolver.from_schema方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_valid
# 需要导入模块: from jsonschema import RefResolver [as 别名]
# 或者: from jsonschema.RefResolver import from_schema [as 别名]
def is_valid(self):
handlers = {'https': self.session_request_json,
'http': self.session_request_json}
resolver = RefResolver.from_schema(self.schema.raw_schema,
handlers=handlers)
try:
validate(self.data, self.schema.raw_schema, resolver=resolver)
except (SchemaError, ValidationError):
return False
return True
示例2: validate
# 需要导入模块: from jsonschema import RefResolver [as 别名]
# 或者: from jsonschema.RefResolver import from_schema [as 别名]
def validate(self):
"""
Validate that this instance matches its schema.
"""
schema = Schema(self.__class__.SCHEMA)
resolver = RefResolver.from_schema(
schema,
store=REGISTRY,
)
validate(self, schema, resolver=resolver)
示例3: validate
# 需要导入模块: from jsonschema import RefResolver [as 别名]
# 或者: from jsonschema.RefResolver import from_schema [as 别名]
def validate(self, instance, schema_id, skip_http=True):
"""
Validate an instance against a registered schema.
"""
schema = self[schema_id]
handlers = {}
if skip_http:
handlers.update(
http=do_not_resolve,
https=do_not_resolve,
)
resolver = RefResolver.from_schema(
schema,
store=self,
handlers=handlers,
)
return validate(instance, schema, resolver=resolver)
示例4: resolver
# 需要导入模块: from jsonschema import RefResolver [as 别名]
# 或者: from jsonschema.RefResolver import from_schema [as 别名]
def resolver(self):
return RefResolver.from_schema(Swagger(self).as_dict())
示例5: refresolver
# 需要导入模块: from jsonschema import RefResolver [as 别名]
# 或者: from jsonschema.RefResolver import from_schema [as 别名]
def refresolver(self):
if not self._refresolver:
self._refresolver = RefResolver.from_schema(self.__schema__)
return self._refresolver
示例6: test_it_can_construct_a_base_uri_from_a_schema_without_id
# 需要导入模块: from jsonschema import RefResolver [as 别名]
# 或者: from jsonschema.RefResolver import from_schema [as 别名]
def test_it_can_construct_a_base_uri_from_a_schema_without_id(self):
schema = {}
resolver = RefResolver.from_schema(schema)
self.assertEqual(resolver.base_uri, "")
self.assertEqual(resolver.referrer, schema)
示例7: test_it_can_construct_a_base_uri_from_a_schema
# 需要导入模块: from jsonschema import RefResolver [as 别名]
# 或者: from jsonschema.RefResolver import from_schema [as 别名]
def test_it_can_construct_a_base_uri_from_a_schema(self):
schema = {"id" : "foo"}
resolver = RefResolver.from_schema(schema)
self.assertEqual(resolver.base_uri, "foo")
self.assertEqual(resolver.referrer, schema)
示例8: validate_subschema
# 需要导入模块: from jsonschema import RefResolver [as 别名]
# 或者: from jsonschema.RefResolver import from_schema [as 别名]
def validate_subschema(data, schema_selector):
schema = load_schema()
resolver = RefResolver.from_schema(schema)
format_checker = FormatChecker()
request_schema = resolver.resolve_from_url(schema_selector)
validate(data, request_schema, resolver=resolver, format_checker=format_checker)