当前位置: 首页>>代码示例>>Python>>正文


Python RefResolver.from_schema方法代码示例

本文整理汇总了Python中jsonschema.validators.RefResolver.from_schema方法的典型用法代码示例。如果您正苦于以下问题:Python RefResolver.from_schema方法的具体用法?Python RefResolver.from_schema怎么用?Python RefResolver.from_schema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jsonschema.validators.RefResolver的用法示例。


在下文中一共展示了RefResolver.from_schema方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_it_resolves_local_refs_with_id

# 需要导入模块: from jsonschema.validators import RefResolver [as 别名]
# 或者: from jsonschema.validators.RefResolver import from_schema [as 别名]
 def test_it_resolves_local_refs_with_id(self):
     schema = {"id": "foo://bar/schema#", "a": {"foo": "bar"}}
     resolver = RefResolver.from_schema(schema)
     with resolver.resolving("#/a") as resolved:
         self.assertEqual(resolved, schema["a"])
     with resolver.resolving("foo://bar/schema#/a") as resolved:
         self.assertEqual(resolved, schema["a"])
开发者ID:clarete,项目名称:jsonschema,代码行数:9,代码来源:test_validators.py

示例2: test_it_can_construct_a_base_uri_from_a_schema_without_id

# 需要导入模块: from jsonschema.validators import RefResolver [as 别名]
# 或者: from jsonschema.validators.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, "")
     with resolver.resolving("") as resolved:
         self.assertEqual(resolved, schema)
     with resolver.resolving("#") as resolved:
         self.assertEqual(resolved, schema)
开发者ID:clarete,项目名称:jsonschema,代码行数:10,代码来源:test_validators.py

示例3: __init__

# 需要导入模块: from jsonschema.validators import RefResolver [as 别名]
# 或者: from jsonschema.validators.RefResolver import from_schema [as 别名]
 def __init__(self, name, schema):
     self.name = name
     self.base_uri = schema.get('id', '')
     # replace all relative references with absolute refs to avoid
     # clashes in self.definitions
     self.schema = Reference.replace_relative_references(self.base_uri, schema)
     # maps full jsonschema fragment path to internal structure,
     # for example a StructDef or a TypeDef.
     self.definitions = {}
     self.refresolver = RefResolver.from_schema(schema)
开发者ID:neumark,项目名称:unimodel,代码行数:12,代码来源:generator.py

示例4: test_it_can_construct_a_base_uri_from_a_schema

# 需要导入模块: from jsonschema.validators import RefResolver [as 别名]
# 或者: from jsonschema.validators.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.resolution_scope, "foo")
     with resolver.resolving("") as resolved:
         self.assertEqual(resolved, schema)
     with resolver.resolving("#") as resolved:
         self.assertEqual(resolved, schema)
     with resolver.resolving("foo") as resolved:
         self.assertEqual(resolved, schema)
     with resolver.resolving("foo#") as resolved:
         self.assertEqual(resolved, schema)
开发者ID:BarnetteME1,项目名称:DnD-stuff,代码行数:15,代码来源:test_validators.py

示例5: validate_schema_value

# 需要导入模块: from jsonschema.validators import RefResolver [as 别名]
# 或者: from jsonschema.validators.RefResolver import from_schema [as 别名]
def validate_schema_value(schema, value, swagger_resolver=None):
    # pass resolver to avoid to refetch schema files
    if swagger_resolver is None:
        swagger_resolver = RefResolver.from_schema(schema)
    create_dereffing_validator(swagger_resolver)(schema, resolver=swagger_resolver).validate(value)
开发者ID:hiromu,项目名称:swagger_spec_validator,代码行数:7,代码来源:ref_validators.py


注:本文中的jsonschema.validators.RefResolver.from_schema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。