本文整理匯總了Python中jsonschema.Draft3Validator.check_schema方法的典型用法代碼示例。如果您正苦於以下問題:Python Draft3Validator.check_schema方法的具體用法?Python Draft3Validator.check_schema怎麽用?Python Draft3Validator.check_schema使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jsonschema.Draft3Validator
的用法示例。
在下文中一共展示了Draft3Validator.check_schema方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: validate
# 需要導入模塊: from jsonschema import Draft3Validator [as 別名]
# 或者: from jsonschema.Draft3Validator import check_schema [as 別名]
def validate(self):
try:
Draft3Validator.check_schema(self.schema)
except SchemaError as err:
return 'schema is invalid: {}'.format(err)
return None
示例2: test_schema_valid
# 需要導入模塊: from jsonschema import Draft3Validator [as 別名]
# 或者: from jsonschema.Draft3Validator import check_schema [as 別名]
def test_schema_valid(self):
"""
The schema itself is a valid Draft 3 schema
"""
Draft3Validator.check_schema(rest_schemas.create_group_request)
示例3: test_0
# 需要導入模塊: from jsonschema import Draft3Validator [as 別名]
# 或者: from jsonschema.Draft3Validator import check_schema [as 別名]
def test_0(self):
"""The schema is valid"""
Draft3Validator.check_schema(self.widget.schema)
示例4: open
# 需要導入模塊: from jsonschema import Draft3Validator [as 別名]
# 或者: from jsonschema.Draft3Validator import check_schema [as 別名]
# Loading example files
client_example_file = open(WORKSPACE_DIR + "schema/communication/examples/client-message-example.json")
server_example_file = open(WORKSPACE_DIR + "schema/communication/examples/server-message-example.json")
client_configuration_example_file = open(WORKSPACE_DIR + "schema/configuration/examples/client-configuration-example.json")
client_logging_example_file = open(WORKSPACE_DIR + "schema/communication/examples/client-logging-example.json")
# Loading into JSON
client_schema = json.load(client_schema_file)
server_schema = json.load(server_schema_file)
client_configuration_schema = json.load(client_configuration_schema_file)
client_logging_schema = json.load(client_logging_schema_file)
client_example = json.load(client_example_file)
server_example = json.load(server_example_file)
client_configuration_example = json.load(client_configuration_example_file)
client_logging_example = json.load(client_logging_example_file)
# Running verification
logging.info("Testing schemes for compliance against the JSON Schema format")
Draft3Validator.check_schema(client_schema)
Draft3Validator.check_schema(server_schema)
Draft3Validator.check_schema(client_configuration_schema)
Draft3Validator.check_schema(client_logging_schema)
logging.info("Testing example files for compliance against respective schemes")
validate(client_example, client_schema)
validate(server_example, server_schema)
validate(client_configuration_example, client_configuration_schema)
validate(client_logging_example, client_logging_schema)
示例5:
# 需要導入模塊: from jsonschema import Draft3Validator [as 別名]
# 或者: from jsonschema.Draft3Validator import check_schema [as 別名]
# How do I validate a JSON Schema schema, in Python?
from jsonschema import Draft3Validator
my_schema = json.loads(my_text_file) #or however else you end up with a dict of the schema
Draft3Validator.check_schema(schema)
示例6: ValueError
# 需要導入模塊: from jsonschema import Draft3Validator [as 別名]
# 或者: from jsonschema.Draft3Validator import check_schema [as 別名]
msg = " check effect %s ... " % filename
try:
effect = json.loads(f.read())
script = path.basename(effect['script'])
if not path.exists(jsonFiles+'/'+script):
raise ValueError('script file: '+script+' not found.')
schema = path.splitext(script)[0]+'.schema.json'
if not path.exists(jsonFiles+'/schema/'+schema):
raise ValueError('schema file: '+schema+' not found.')
schema = jsonFiles+'/schema/'+schema
# validate against schema
with open(schema) as s:
effectSchema = json.loads(s.read())
Draft3Validator.check_schema(effectSchema)
validator = Draft3Validator(effectSchema)
baseValidator.validate(effect)
validator.validate(effect['args'])
#print(msg + "ok")
except Exception as e:
print(msg + 'error ('+str(e)+')')
errors += 1
retval = 1
print(" checked effect files: %s success: %s errors: %s" % (total,(total-errors),errors))
sys.exit(retval)