def parse_schema(schema):
if type(schema) is six.binary_type or type(schema) is six.text_type:
return {
'type': schema,
}
elif type(schema) is list:
return {
'type': 'list',
}
elif type(schema) is dict:
title = schema.get(':title', None)
required_elts = list(get_required(schema.keys()))
properties = get_object_properties(schema)
return {
'type': 'object',
'title': title,
'properties': {
prop_name: parse_schema(subschema)
for prop_name, subschema in properties.items()
},
'required': required_elts,
}
else:
raise Exception('Unsupported schema definition')
评论列表
文章目录